Command mode (move cursor, copy, cut D, paste p, delete x, Undo U, Redo Ctrl+r, replace R)
Insert mode (write new data) A (post-word insert) I (insert before word) O (Insert new line)
Last-line mode (save File W, Save as W filename, open file o, read file R, find replacement s)
Command mode
Move cursor
H left, J down, k up, L right
Beginning ^
End of Line $
First line 1G or GG
Last line G
W jumps down a word
Copy y
YY Copy Bank
2yy Copy 2 rows
YW copy a word
y^ copying to the beginning of the line
y$ Copy to end of line
Ygg Copy to First line
YG Copy to last line
Cut D
Using methods and replication are similar
No paste after cut, i.e. delete
Delete x
Delete the character that the cursor contains
Find:/< keywords > go after (n\n)
:?< keyword > looking forward from behind
Save Exit ZZ
Merge rows (delete line return) J
Last-line mode
Find Replacement: 3,5D cut 3 to 5 rows
: 3,5y copy 3 to 5 rows
: Range s/old/new/option
: 1,3 s/old/new/g Replace all old 1 to 3 rows with new
: 1,3 S/old/new Replace the first old 1 to 3 rows with the new one
: 1,$ s/old/new Replace the first old of 1 to the last line with the new one
:% s/old/new Replace the first old of all rows with the new one
:% s/old/new/g Replace all old with new
Save and exit
: W/aaa.txt saved as/aaa.txt
: 1,3 W/2.txt 1 to 3 behavior of saving files 2.txt file
: r/etc/passwd read the file to the line below the cursor
: Enter line 10th
: W Save
: Q exit
:! Forced
Copy 2,4y copy 2 to 4 rows
Show line number set Nu
Line number set Nonu not displayed
Insert mode
V Visual Mode line selection
V Visual mode character selection
Ctrl + V Visual Block selection
Ctrl + V Select a vertical bar, enter I (uppercase I) into the INSERT, enter the text that needs to be inserted before each line, press ESC to exit Auto-generate.
When you open multiple files at the same time
: Next Next file
:p Rev A previous file
: First oldest file
: Last File
Window segmentation
: Split < file name > split horizontally open Window
: Vsplit < file name > Portrait split open Window
Vimdiff grub.conf/etc/grub.conf displays different parts of the file, up to four files in comparison. ^w Press two times to switch
Vim-o test1.txt test2.txt Horizontal Split window open two files (alignment effect)
Vim-o test1.txt test2.txt Vertical Split window open two files (alignment effect)
Vim configuration file VIM/ETC/VIMRC
========================================
Binary file (strings grep)
# strings/bin/ls Viewing binary file contents
==================================================
==================================================
This article from "Green Forest" blog, declined reprint!
Bash command/file Management-vim operation