Chapter 9: Use the editor
1. Vim Editor
(For more details, see #1, #2, #3)
Start:Vim or Vim File
Two editing modes:Normal Mode and insert mode. Normal Mode is enabled by default.
Move the cursor:
H: 1 character left
J: move down a row
K: Move up a row
L: Shifts 1 character to the right
Pagedown, CTRL + F: one screen flip down
Pageup, CTRL + B: one screen up
G: Move to the last row of the buffer.
NumG: Move to the bufferNumLine
GG: Move to 1st rows in the buffer zone
Commands in edit mode
| Command |
Description |
| X |
Delete the character at the cursor position |
| Dd |
Delete the row where the cursor is located |
| DW |
Delete a word at the cursor position |
| D $ |
Delete the content from the cursor position to the end of the row |
| J |
Delete the line break at the end of the row where the cursor is located (concatenate rows) |
| U |
Undo the previous edit command |
| A |
Append data after the current cursor |
| A |
Append data at the end of the row where the current cursor is located |
| R char |
Use Char to replace a single character at the position of the current cursor |
| R text |
Overwrite the data at the cursor position with text until you press the ESC key. |
Some commands allow the specified number of executions (see Figure #2)
Copy and paste
The Copy command is Y and its usage is the same as D (YW = copy word, y $ = copy to end of line)
In normal mode, move the cursor to the beginning of the text to be copied, press V, move the cursor to the end of the text to be copied, and press y to activate the copy.
P is pasted
Search and replace
In normal mode, press the slash (/) and enter the search content and press Enter.
Replacement command
: S/old/new/G: replace all old
: N. ms/old/new/G: replace all old values between N and M.
: % S/old/new/G: replace all old
: % S/old/new/GC: replace all the old values in the file. A prompt is displayed for each replacement.
Command mode in normal mode (by colon in Normal Mode)
Q: exit if the buffer is not modified.
Q! : Do not save, exit
W filename: Save the file as filename
WQ: Save and exit
2. emacs editor
Start:Emacs file. To use the Console mode, add the-NW option.
Emacs only has one mode. If you enter visible characters, emacs inserts characters at the cursor. Enter the command and Emacs executes the command.
Move the cursor:
C-P: Move up a row
C-B: 1 character left
C-F: Shifts right to 1 Character
C-N: move down a row
Pageup: Next page
Pagedown: Previous Page
M-F: move right to the next word
M-B: Move left to the previous word
C-A: Move to the beginning of the line
C-E: Move to the end of the row
M-A: Move to the beginning of the current sentence
M-E: Move to the end of the current sentence
M-V: one screen up
C-V: Flip the screen
M-<: Move to the first line of text
M->: Move to the end of the text
Save:
C-x C-S: Save
C-Z: Exit Emacs and keep running in this session to switch back
C-x C-C: Exit Emacs and stop the program.
The C-x command is called the Extend Command)
Edit data:
Delete: backspace and del
Cut:
M-backspace: Cut the word before the current position of the cursor
M-D: Cut the word after the cursor's current position
C-K: Cut the text from the current position of the cursor to the end of the line
M-K: Cut the text from the current position of the cursor to the beginning of the line
Copy and paste:
C-Y: extract the text stored in the last cut command. If multiple cut commands are executed, use M-y to select them cyclically.
Search and replace:
C-S: search from the cursor to the end of the buffer
C-r: Search from cursor to buffer start
Progressive (incremental): the emacs editor searches for text in real time.
Non-incremental: complete input before searching
M-X: replace. Enter commands and parameters. Enter the replace-string command, press enter, enter the search character, press enter, enter the replacement character, and press ENTER
Use a buffer in Emacs
Emacs allows you to edit multiple files simultaneously using multiple buffers.
C-x C-F: Load new files to the buffer zone. This is the find a file mode for Emacs.
C-x C-B: List working Buffers
In addition to the primary buffer zone, emacs also provides two buffers:
1. The draft area is called * scatch *. Allow input of Lisp commands and notes for yourself
2. The message region is called * messages *. Displays messages generated by Emacs in the action.
Two ways to switch to different buffer areas in the window
C-x O: switch to the buffer List window.
C-x B: enter the name of the buffer to switch.
Use the window in Emacs in Console mode
C-x 2: Split the window horizontally into two windows.
C-x 3: Split the window vertically into two windows.
C-x 0: Close the current window
C-x 1: Close all other windows
C-x O: switch window
Note: When creating a new window, emacs uses the original window buffer in the new window.
Use Emacs (P185) in XWindow)
3. KDE Series Editor
Kwrite Editor
Command line parameters:
-- Stdin: enables kwrite to read data from standard input devices rather than files.
-- Encoding: Specifies a character encoding type for the file.
-- Line: Specifies the row number of the file starting in the editor window.
-- Column: Specifies the column number of the file starting in the editor window.
(For other graphical content, see p186)
Kate Editor (see p190)
4. gnome Editor
Gedit Editor (see p192)
1. UNIX & Linux University tutorial-Chapter 22nd (1) Study NotesVI Text Editor (1)
2. UNIX & Linux University tutorial-Chapter 2 (ii) Study NotesVI Text Editor (2)
3. UNIX & Linux university course-Chapter 22nd (iii) Study NotesVI Text Editor (III)
Repost the following link
My blog address
Http://su1216.iteye.com/
Http://blog.csdn.net/su1216/