170 likes | 343 Views
Chapter 5. Using Linux Text Editors. Overview. Use Non-Graphical Linux Text Editors Graphical Text Editor. Overview. Configuration information is stored in a variety of text files, in the /etc directory Using a text editor to edit these files to customize the system. $ vi /etc/inittab.
E N D
Chapter 5 Using Linux Text Editors
Overview • Use Non-Graphical Linux Text Editors • Graphical Text Editor
Overview • Configuration information is stored in a variety of text files, in the /etc directory • Using a text editor to edit these files to customize the system. $ vi /etc/inittab
Using the vi Editor • Two versions of vi • vi • vim (Vi IMproved) • Replacing vi version on the most newer Linux distributions • Located in /bin • When execute the vi program, /usr/bin/vi file called • This is a symbolic link file, points to the /bin/vim executable file
Using the vi Editor • Excute vi program by press vi or vim , to call /bin/vim
vi Modes ■ Normal mode ■ Insert mode ■ Command mode ■ Replace mode • Default , vi opens file or creates a new file in normal mode • Command mode use to write, search, or close file
vi Modes • Switch to Insert mode press I or S • Switch to Replace mode press <Insert> • Switch to Command mode press ESC and press : • Escape current mode press ESC
Working in Normal mode • Open File to exec vi in normal mode vi vidu.txt • vi automatically switch from normal mode to insert mode when you enter text. • When you need to edit text : • Press ESC to switch to normal mode • Press dw, de, d$, dd, p, u, /search_term
Entering Commands in vi Normal Mode ■ dwDeletes the word that comes immediately after the cursor, including the space following the word. The text is saved in a memory buffer. ■ de Deletes the word that comes immediately after the cursor, not including the space. The text is saved in a memory buffer.
Entering Commands in vi Normal Mode ■ dd Deletes the entire current line. The text is saved in a memory buffer. ■ d$ Deletes from the insertion point to the end of the line. The text is saved in a memory buffer ■ p Inserts the text deleted in the last deletion operation after the current cursor location ■ u Undo the last action.
Entering Commands in vi Normal Mode ■ CTRL-G Displays a status line at the bottom of the interface. This displays the name of the file, the total number of lines in the file, and the current cursor location. This is shown in Figure 5-15. ■ /search_term Searches for the instance of the term specified.
Commands in Command mode ■ w and ENTER Writes the current file ■ w filename and ENTER Writes the current file to a different file name ■ exit and ENTER Writes the current file and then closes vi. Or press wq ■ q Closes vi without saving the current file. This can only be used if the file hasn’t been changed. If the file has been changed, then you must enter q!
Using the vi Editor Exercise 5.1Page: 234
Using the Emacs Editor Exercise 5.2Page: 241
Use Graphical Text Editors It work if: ■ The system is working properly. ■ The system has X Windows, a window manager, and a desktop installed. ■ Your X Window System has been configured properly to work with your hardware Some of graphic editors are : • Kate • X emacs • gedit