introduction to the gedit editor

51
Introduction to the gedit editor

Upload: alban

Post on 11-Feb-2016

122 views

Category:

Documents


3 download

DESCRIPTION

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.). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to the gedit editor

Introduction to the gedit editor

Page 2: 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

Page 3: Introduction to the gedit editor

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)

Page 4: Introduction to the gedit editor

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 !

Page 5: Introduction to the gedit editor

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)...

Page 6: Introduction to the gedit editor

Running the gedit application

• Run gedit by entering this command in a shell window (terminal):

The UNIX prompt can be different for different users (it's user settable)

UNIX prompt >> gedit

Page 7: Introduction to the gedit editor

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

Page 8: Introduction to the gedit editor

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)

Page 9: Introduction to the gedit editor

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)

Page 10: Introduction to the gedit editor

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

You will see the gedit window

UNIX prompt >> gedit &

Page 11: Introduction to the gedit editor

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)

Page 12: Introduction to the gedit editor

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

Page 13: Introduction to the gedit editor

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

Page 14: Introduction to the gedit editor

Creating a new file (document) with gedit (cont.)

• You will see a new tab corresponding to a file named Untitled 1:

Page 15: Introduction to the gedit editor

Keyboard shortcuts

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

Page 16: Introduction to the gedit editor

Keyboard shortcuts (cont.)• Example: • The keyboard shortcut for new file is control-N

See:

Page 17: Introduction to the gedit editor

Keyboard shortcuts (cont.)

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

Page 18: Introduction to the gedit editor

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

Page 19: Introduction to the gedit editor

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)

Page 20: Introduction to the gedit editor

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

Page 21: Introduction to the gedit editor

Replacing some text

• How to replace text:

• Delete the text

• Insert new text

Page 22: Introduction to the gedit editor

Goto a certain line in the file

• A feature that is very useful when you write computer programs is:

• 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 a file

Page 23: Introduction to the gedit editor

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

Page 24: Introduction to the gedit editor

Goto a certain line in the file (cont.)

Example:

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

Page 25: Introduction to the gedit editor

Goto a certain line in the file (cont.)

• Keyboard shortcut:

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

Page 26: Introduction to the gedit editor

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

Page 27: Introduction to the gedit editor

Search for a text pattern (cont.)• Example

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

Page 28: Introduction to the gedit editor

Search for a text pattern (cont.)

• Keyboard shortcut:

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

Page 29: Introduction to the gedit editor

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

Page 30: Introduction to the gedit editor

Search for a text pattern – continued (cont.)

Example:

Page 31: Introduction to the gedit editor

Search for a text pattern – continued (cont.)

• Keyboard shortcut:

• The keyboard shortcut for the Find Next function is control-G

Page 32: Introduction to the gedit editor

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

Page 33: Introduction to the gedit editor

Search and Replace (cont.)

Example:

Page 34: Introduction to the gedit editor

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

Page 35: Introduction to the gedit editor

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:

Page 36: Introduction to the gedit editor

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.

Page 37: Introduction to the gedit editor

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

Page 38: Introduction to the gedit editor

Search and Replace (cont.)

• Keyboard shortcut:

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

Page 39: Introduction to the gedit editor

Undo a change

• When you make a edit mistake, you can undo the last change with the undo-command:

• Undo earlier changes:

• control-Z

• You can undo earlier changes by pressing control-Z multiple time

• The maximum number of changes can be undo is 25

Page 40: Introduction to the gedit editor

Undo a change (cont.)

• Changing the maximum number of undo's:

• Click on the Edit tab

• Then click on Preferences tab.

Page 41: Introduction to the gedit editor

Undo a change (cont.)• A window will pop up

Change the value in the Limit to field:

Click Close when you're done.

Page 42: Introduction to the gedit editor

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)

Page 43: Introduction to the gedit editor

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

Page 44: Introduction to the gedit editor

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

Page 45: Introduction to the gedit editor

Saving your work (cont.)

• A new window will pop up:

Enter a new filename and press Save

Page 46: Introduction to the gedit editor

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:

Page 47: Introduction to the gedit editor

Quit the edit session without saving any changes made (cont.)

• Left click on the File button • Then Left click on the Quit button:

Page 48: Introduction to the gedit editor

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 !!!)

Page 49: Introduction to the gedit editor

Make backups of your files

• Advice:

• Make copies of your projects regularly

Especially, when you have reach a milestone in your project

Page 50: Introduction to the gedit editor

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

Page 51: Introduction to the gedit editor

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:

where xxxxxxxx is the name of the file that you want to backup.

• xxxxxxxx-ver1           

• xxxxxxxx-ver2

• And so on