C++ CSS HTML Java JavaScript MySQL Oracle PERL PHP SQL Unix VBScript XHTML XML Сети
Editing Text Files
 

9.2. Editing Text Files

Red Hat Linux includes several text editors, applications that allow you to view and modify plain text files. Plain text files are files that contain text without any font or style formatting applied to it, such as system logs and configuration files.

gedit gedit has a clear and understandable interface that uses tabs so that you can open more than one file at the same time without opening more than one gedit window.

To start gedit, click Main Menu => Accessories => Text Editor. You can also start gedit by typing gedit at a shell prompt.

NoteNote
 

gedit can only be used in a graphical desktop environment.

Figure 9-8. gedit

Once gedit is running, you are presented with a blank editing area. You can begin using gedit immediately or click the Open button to locate the plain text file you want to edit. The file will load into the main editing area as shown in Figure 9-8 file line-by-line. Press the [Page Up] and [Page Down] keys to advance the document a page at a time.

TipTip
 

geditOpen, choose the file you want to access, and the file will open in a new tab within the gedit window. You can navigate between each file by clicking on the the tab associated with the particular filename.

Once you have modified or written your text file, you can save it by pressing the Save button in the toolbar, or by choosing File => Save changes you make will automatically appear in the file the next time you open it. You can also choose File => Save As... original configuration.

For more information about gedit, choose Help => Contents from the file menus to access the gedit manual.

9.2.1. Shell Prompt Text Editors

If you are not using a graphical desktop and want to read and modify a text or configuration file, Red Hat Linux includes the vi (pronounced vee-eye) text editor. vi is a simple application that opens within the shell prompt and allows you to view, search, and modify text files. To start vi, type vi at a shell prompt. To open a file with vi type vi <filename> at a shell prompt.

Figure 9-9. vi

By default, vi opens a file in Normal mode, meaning that you can view and run built-in commands on the file but you cannot add text to it. To add text, press [i] (for Insert mode), which will allow you to make any modifications you need to. To exit insert mode, press [Esc], and vi reverts to Normal mode.

To exit vi, press [:] (which is the vi command mode) and press [q] then [Enter]. If you have made changes to the text file that you want to save, press [:] and type [w] then [q] to write your changes to the file and exit the application. If you accidentally made changes to a file and you want to exit vi without saving the changes, type [:] and then type [q] followed by [!], which exits without saving changes.

More information about using vi can be found by typing man vi at a shell prompt.

Главная