Cut & Paste
dw
: delete word until the start of the second word.
d2w
: delete until the start of the third wordd$
: delete till the end of the sentence.- w: start of next word
- e: end of current word
- $: end of current sentence
u
: undo one action
U
: undo all the actions token on the liney
: copy the selected texts.p
: if you usedd
to delete one sentence, the whole sentence is memorized, so dd performs like cut operation.
Then you can pressp
to paste that sentence under the cursor.
Search & Replace
r
: replace the current letter once.
R
: continue replace letter.ce
: delete all the letters from the cursor till the end of the word, and into edit mode.Ctrl+G
: show the current line number.: xx
: search xx in the document.%
: match the corresponding bracket, like (, {, [.s/old/new/g
: replace all the old in the current line with new.
%s/old/new/g
: replace all the old in the whole document with new.Ctrl+o
: jump back the the previous place.
Execute outer commands inside Vim
!command
: execute outer command, like!ls
can list all the files in current folder.w new_file
: save the current file as new_file in the current folder.v
: select some text. After selected some text usingv
command, type:
, then typew filename
, can save the selected text into filename in current folder.r filename
: import text from filename into current line.
Get help info
help xx
: get help information about xx command. The will open a new vim windows.Ctrl+w:
change between different vim window.Ctrl+D
: list all possible command.Tab
: complete the code