The most common use of vim to edit a single file, see the source code. is to write a few K line of code when there are no other plug-ins, just set a highlight and some of the properties of their own. The advantage is that it can be used immediately on any new machine.
On the internet, a lot of "vim command Collection", "the vim to make an IDE" and other articles, I think at least it means little to me. I think the following commands are ripe, VIM is a very useful tool, enough for daily use.
Open/exit
Vim-R file1 read-only open: Qall exit All Files: Wq write and exit: Q! Force exit
Insert
I insert a in the current line at the beginning of the current position insert a at the end of the current row insert an O insert a row after the current line O insert a row before the current row
Move
H Move left one character L move right one character K move up one character J Move down one character
The above four commands can be used with the number, such as 20J is to move down 20 lines, 5h is to move 5 characters to the left.
Delete
DD Delete current row DJ Delete current line and previous line DK Delete current line and next line 10DD Delete Current line start of total 10 rows D Delete current character to end of line
Jump
GG jump to file header g Jump to file end gg=++ ++ b scroll up one screen colon + line number, jump to the specified line; For example:120 , jump to line 120; $ jump to line end 0 jump to beginning
Edit
+ R Redo yy Copy the current line press V (verbatim) or V (line by row) into the visual mode, and then move with the JKLH command to select some rows or characters, and then press Y to copy any part P paste in the current position in addition, the deletion in Vim is the meaning of shearing, so DD is cut the current line, You can select a specific part with V or V and press D to cut it arbitrarily.
Find
/text find text, press N to find the next, press N to find the previous one ? text find text, reverse lookup, press N to find the next, press N to find the previous one: Set IgnoreCase ignores case-finding: set noignorecase do not ignore case-finding
Replace
: s/old/New/replace with old with new, replacing the first match of the current line: s/old/new/G replaces all occurrences of the current row with old new, substituting:%s/old/ new/replace new with old, replacing the first match for all rows:%s/old/new/G replaces new with old, replaces all matches for the entire file, or selects the specified row with V or v. And then execute
Multi-file operation
vim file1 file2 file3 ... Edit multiple files simultaneously: Split divides the window into the top and bottom two sub-windows, corresponding to two different files: vsplit the window into the left and right two sub-windows, corresponding to two different files: Open file4 Opens new file: bn switches to the next file (current window): BP Switch to the previous file (current window) Ctrl-W H move to theleft of the window Ctrl-W J move to the bottomof the window Ctrl-w K move to the top of thewindow Ctrl + W L move to the right of the window
Section excerpt from:
Http://www.cnblogs.com/softwaretesting/archive/2011/07/12/2104435.html
Common commands for Vim