VIM text editing tool
VIM: a text editing tool
Three main modes
Mode conversion
Close the file
Extended command mode
: Q exit: Q! Force exit, discard changes made: wq save exit: X save exit
Command mode:
ZZ save exit ZQ does not save exit extended command mode: common command w write (save) disk file wq write and exit x write and exit Q exit Q! Exit without saving the disk, even if you change it, you will lose the contents of the r filename read file to the current file w filename writes the contents of the current file to another file! command executes the command ringing command reads the output command mode cursor jumps:
Jump between characters:
H: left l: right j: next k: top # COMMAND: jump to the number of characters specified by #
Jump between words
W: the beginning of the next word e: the suffix of the current or next word b: the beginning of the current or previous word # COMMAND: the number of words to jump specified by #
Current page jump:
H: top M: middle line L: bottom zt: move the current line of the cursor to the top of the screen zz: move the current line of the cursor to the middle of the screen zb: move the current line of the cursor to the bottom of the screen command mode cursor jump
Jump at the beginning and end of the line:
^ Jump to the first non-white space character at the beginning of the line 0 to the beginning of the line $jump to the end of the line
Interline movement
# G or extended command mode: # Jump to the last line 1G from line # G, the first line of gg
Inter-sentence movement
) next sentence (previous sentence )
Move between paragraphs
Next paragraph {previous command mode flip screen operation Ctrl+f turn a screen to the end of the file Ctrl+b turn a screen to the head of the file Ctrl+d turn half the screen to the end of the file Ctrl+u flip half to the head of the file command mode operation
Character editing
X delete the character at the cursor # x delete the beginning of the cursor the position of the character at and after the xp swap cursor ~ convert case J the newline character after the current line is deleted
Replace command (r, replace)
R replace the character R at the cursor and switch to REPLACE mode
Delete command
D delete command, can be combined with the cursor jump character to achieve range deletion d$ delete to the end of the line d^ delete to the beginning of the non-empty line d0 delete to the beginning of the line dw de db # COMMAND dd: delete the line where the cursor is located # dd multiple lines delete D: delete from the current cursor position to the end of the line, which is equivalent to d$
Copy command (y, yank)
Y copy, similar to the d command y$ y0 y ^ ye yw yb # COMMAND yy: copy line # yy copy multiple lines Y: copy the entire line
Paste command (p, paste)
If the P buffer is the whole line, paste below the line of the current cursor; otherwise, paste to the back of the current cursor, if the P buffer is the whole line, paste the top of the line of the current cursor; otherwise, paste to the front of the current cursor
Change command (c, change)
C: switch to insert mode after modification
Command mode-- > insert mode
C $c ^ c0 cb ce cw # COMMAND
Cc: delete the current line and enter new content, which is equivalent to S
Cc
C: delete the current cursor to the end of the line and switch to insert mode
Find
/ PATTERN: from the current cursor to the end of the file? PATTERN: from the current cursor to the head of the file n: in the same direction as the command N: opposite to the command
Undo changes
U undo recent changes # u undo multiple changes before undo U undo cursor falls on this line all changes to this line Ctrl-r redo the last "undo" change . Repeat the previous operation #. Repeat the previous operation # times to learn more