Using gedit

A text editor is an essential tool for your GNOME desktop. From writing a small document, editing a configuration file, or composing a webpage, gedit will fill your need.

Starting gedit opens the Main window.

Figure 1. gedit Main Window

From here you see the menu bar which has all the options and tools for gedit. You also see the toolbar with all the basic commands you will probably use the most in gedit. If you right-click on the text window, under the toolbar, a pop-up menu will appear displaying some common editing and file commands.

Gedit has plug-ins so you can send a quick email to a friend, lookup a webpage if you need help with your work, or produce a file that tells the difference between two other files, using the diff command. The shell output plugin inserts the output of any shell command into gedit. Gedit's plug-ins will let you insert the current time in your document, as it appears in date, insert the phrase "Hello World" in your current document, reverse the letters in the current document you're editing, or convert a decimal number to either a hexidecimal or octal number [1] and back again.

Using gedit from the Command line

Gedit can also be started from the command line, by typing gedit with the name of the file you want to edit. This will open a new Main Window of gedit with the file you typed in the command line. You can also open multiple files in gedit from the command line. You type gedit with each file's name, separated by a space, after the command gedit. So, to open the three files file1.txt, file2.txt, and file3.txt, you need to type gedit file1.txt file2.txt file3.txt in a terminal and gedit will open the three file listed above. This feature is very handy to quickly edit a configuration file or script while you are using your favorite shell.

Note

If you open a file using gedit from a X terminal and then kill the X terminal, the gedit you opened will also be killed. This happens because gedit is a child process of the X terminal, the parent process. In the Unix environment if you kill the parent process, all the child processes that are spawned by the parent process are killed. Killing all the "children" of the parent process is very useful in a Unix environment. It's really okay if you don't understand the above explanation. Just remember if you open gedit in a X terminal and kill the X terminal, gedit will also be killed.

Gedit also has support for pipes when you use it in a console or X terminal. When you use a pipe with gedit, on the command line, Gedit is opened and the output of the other command that is piped to gedit is displayed as a text file in gedit's Main Window. For example if you want to display a listing of what files are in a specific directory using the ls command, you will type ls | gedit. [2] The output of ls, that is normally displayed on the console or X terminal, will be displayed in gedit as a new text file. This option is very useful for commands that display their output too fast or if you want to use the output in a text file.

Notes

[1]

Decimal, hexidecimal, and octal numbers are number with a different base. A decimal number has a base of 10, these are numbers you see everyday, hexidecimal number has a base of 16, and octal numbers have a base of 8. So, a decimal number of 45 would be 2D in hexidecimal, and 55 in octal.

[2]

The | (pipe) character varies from keyboard to keyboard, but it will, most often, be underneath the \ (backslash)character. Some common places to look for the pipe character is: to the right on the shift key on the right side of the keyboard, to the right of the ] (square bracket) key or above the enter key on the right side of the keyboard, or to the left of the backspace key on the right side of the keyboard.