You are on page 1of 51

Introduction to the gedit editor

gedit: the Gnome editor


Gnome:
Gnome is a freely available (i.e., no cost) desktop
environment for the UNIX system
The Gnome project website: http://www.gnome.org/
The computers in the MathCS lab are using Gnome

gedit: the Gnome editor (cont.)


gedit:
gedit = the official text editor of the GNOME desktop
environment.
(Editor = a computer application that let users edit
computer files)

Before we start....
This webnote is not a full training in using gnome
It is mean to get you started.
You will learn additional features through word-of-mouth
from lab assistants and fellow students in the MathCS lab
The best way to learn how to use a program is ask
someone that knows it
So: when you work in the MathCS lab and don't know how
to do something, go ask the lab assistant !

What you will be learning to do with


gnome

Things you need to learn to get started with gedit:


Run the gedit application
Create a new file
Insert text into the file
Delete text from the file
Go to a certain line in the file
Search for a pattern in the file

Search and replace for a pattern with another pattern in


the file
Undo a change
Save your work
Quit without saving (because you made a mess)...

Running the gedit application


Run gedit by entering this command in a shell window
(terminal):
UNIX prompt >>
gedit
The UNIX prompt can be different for different users (it's
user settable)

Applications that are attached and detached


from the terminal
Attached and detached:
An application be attached or detached from the
terminal
When an application is attached to the terminal, you
can interact with that application through the keyboard
In other words: the attached application will receive the
keystrokes you enter through the keyboard
When an application is detached to the terminal, you
cannot interact with that application through the
keyboard
In other words: the attached application will not receive
the keystrokes you enter through the keyboard

Applications that are attached and detached


from the terminal (cont.)
Example (demo):
1. Run gedit from a terminal window
2. When you see the gedit window, click on the terminal
window (to get the input focus)
3. Type control-C (hold the control-key and press C)
This will kill the running application (in most cases)

Applications that are attached and detached


from the terminal (cont.)
We can kill the gedit application because the application
was attached
In other words, the gedit application receives the control-C
through the keyboard (and got killed)

Running applications in the detached


manner
You can run any applications in UNIX in the detached
manner by appending the "&" character at the end of the
command
Example: running gedit in detached manner
UNIX prompt >>
gedit &
You will see the gedit window

Running applications in the detached


manner (cont.)
Difference:
You can enter more commands in the terminal
window
The keystrokes that you enter in the terminal
window will be executed by the shell application
Type control-C (hold the control-key and press C)
in the terminal window
This will not affect the gedit application
(Because the gedit application is not receiving input
from the keyboard in the detached state)

Computer Science jargon: background


process
Terminology:
An application running in the detached manner is
said to run in the background
A background process is an program (application)
that is running in the detached mode

Creating a new file (document) with gedit


How to get a new (blank) file in gedit:
Click on the File tab
Then click on the New tab

Creating a new file (document) with gedit


(cont.)
You will see a new tab corresponding to a file named
Untitled 1:

Keyboard shortcuts
Keyboard shortcuts are operations that are entered through
key stroke (on the keyboard)

Keyboard shortcuts (cont.)


Example:
The keyboard shortcut for new file is control-N
See:

Keyboard shortcuts (cont.)


When you type control-N in the gedit window, you will
also get a new (black) document)

Inserting text in the file


How to insert text in the document
1. Click at the location where the text is to be insert
2. Type in the text

Insert text by copy and paste


You can insert text from another window into the
document in gedit by using the copy and paste facility:
1.

Highlight any text in a window (e.g., from a webpage) by:

Left click on the first character of the text

Hold the mouse button and drag the mouse to the last
character of the text

Release the mouse button

1.

The highlighted text is automatically copied in UNIX

2.

(On a Windows-based PC, you need to type control-C to


copy)

3.

Now click in the gedit window at the position where you


want to insert the highlighted text

4.

Type control-V (for paste)

Deleting text from a file


How to delete text from a file:
Highlight the text in gedit that you want to
delete
Press the delete key

Replacing some text


How to replace text:
Delete the text
Insert new text

Goto a certain line in the file


A feature that is very useful when you write computer
programs is:
Goto a certain line in a file

That is because compilers (an application that translates a


program written in a high level language into machine
code) always report an error along with the location (as a
line number) in the file.

Goto a certain line in the file (cont.)


How to go to line number n in a file:
1. Left click on the Search tab
2. Then left click on the Go to Line tab

Goto a certain line in the file (cont.)


Example:

After this, a window will pop up and you can enter the
desired line number

Goto a certain line in the file (cont.)


Keyboard shortcut:
The keyboard shortcut for the Go to Line
function is control-I

Search for a text pattern


Finding the first occurrence of a pattern in a file:
1. Left click on the Search tab
2. Then left click on the Find tab

Search for a text pattern (cont.)


Example

After this, a window will pop up and you can enter the search
text pattern

Search for a text pattern (cont.)


Keyboard shortcut:
The keyboard shortcut for the Find First
function is control-F

Search for a text pattern - continued


Finding the next occurrence of a pattern in a file:
1. Left click on the Search tab
2. Then left click on the Find Next tab

Search for a text pattern continued


(cont.)
Example:

Search for a text pattern continued


(cont.)
Keyboard shortcut:
The keyboard shortcut for the Find Next
function is control-G

Search and Replace


Finding the next occurrence of a text pattern in a file and
replace it with some other pattern:
1. Left click on the Search tab
2. Then left click on the Replace tab

Search and Replace (cont.)


Example:

Search and Replace (cont.)


3. You will see the following pop up window:

Enter in the Search for area, the text you want to replace
Enter in the Replace with area, the new text
4. Then press the Find button

Search and Replace (cont.)


5.

If the "Search for" text was found, gedit will stop and let you
replace the found text.
Press the Replace button to replace the text:

Search and Replace (cont.)


If you do not want to replace a particular occurrence of the
matched pattern, then press the Find button (located to the
right of the Replace button)
Gedit will then move to the next matching pattern.

Search and Replace (cont.)


After the replace operation, gedit will find the next
occurrence and ask you if you want to replace
Press Close to stop the Search and Replace operation

Search and Replace (cont.)


Keyboard shortcut:
The keyboard shortcut for the Find Next function
is control-R

Undo a change
When you make a edit mistake, you can undo the last
change with the undo-command:
control-Z
Undo earlier changes:
You can undo earlier changes by pressing
control-Z multiple time
The maximum number of changes can be undo is
25

Undo a change (cont.)


Changing the maximum number of undo's:
Click on the Edit tab
Then click on Preferences tab.

Undo a change (cont.)


A window will pop up
Change the value in the Limit to field:

Click Close when you're done.

Undo an "undo"
Suppose you have undone a change that was in fact correct
You can undo an undo operation using:
shift-control-Z (this is called a Redo operation)

Saving your work


Saving your document:
Left click on the File button
Then Left click on the Save button

If your file does not have a file name, you will be


prompted to enter a name

Saving your work (cont.)


Saving your document under a new filename:
Left click on the File button
Then Left click on the Save As button

Saving your work (cont.)


A new window will pop up:

Enter a new filename and press Save

Quit the edit session without saving any


changes made
If you made a severe error that cannot be easily undone --(and you have not save the changes yet) --- you can quit
the gedit application without saving as follows:

Quit the edit session without saving any


changes made (cont.)
Left click on the File button
Then Left click on the Quit button:

Quit the edit session without saving any


changes made (cont.)
A new window will pop up:

Press the Don't Save button to discard the changes made


Do not press the Save button (or else, your file will be
updated with the mistakes !!!)

Make backups of your files


Advice:
Make copies of your projects regularly
Especially, when you have reach a milestone in
your project

Make backups of your files (cont.)


Suggestion on how to organize your backup files:
Each student has a project directory for this
course named cs170 The cs170 project directory
is located inside your home directory
Make a directory named backup inside your
cs170 project directory
Put backup copies of your project files inside
this backup directory

Make backups of your files (cont.)


You can put different copies of the same project file in the
backup directory by using different names
I recommend to use names like:
xxxxxxxx-ver1
xxxxxxxx-ver2
And so on
where xxxxxxxx is the name of the file that you want to
backup.

You might also like