A detailed description of the VIM command for Linux

Source: Internet
Author: User

Advanced some of the editor, will contain the macro function, Vim is certainly not missing, the use of macros in Vim is very convenient:
: QX starts recording macro and registers the result in register X
Q Exit Record mode
@x playing macro commands recorded in the X register
To explain a little bit, when entering in normal mode: After QX, all your edits to the text will be recorded and entered Q again to exit the recording mode
Type, and then enter @x to repeat the command just recorded, this command can be followed by a number, indicating how many times to repeat, such as @x20, can be repeated 20 times. This is very useful in batch processing of text.
Edit multiple files at the same time
In the many Vim plug-ins, there is a plug-in called Minibuffer, that is, the following tab function, you can support the simultaneous editing of multiple files.
Label command
: tabe fn Edit file in a new tab FN
GT Switch to next tab page
GT Switch to previous tab page
: TABR switch to the first tab page
: tabl switch to the Last tab page
: TABM [n] Moves the current tab to the Nth tab
Yes, as you can imagine, with Eclipse, UE and other tabs is a meaning!
Window commands
ctrl+w s horizontal Split window
Ctrl+w w Switch window
Ctrl+w Q exits the current window (this command does not affect other windows because there are multiple files at the same time)
Ctrl+w v Vertical Split window
Other
Vim does not make any actual changes to the file until it is saved, but it is loaded into the buffer, and the edit of the file is actually the edit of the buffer until: W will be stored in the physical file.
: E file loads the file into the new buffer
: Bn jumps to the next buffer
: BD Delete buffer (close file)
: SP fn Splits the window and loads FN into a new window
Exit editor
: W writes buffer to file, saving modify
: Wq Save changes and exit
: x Save changes and exit
: Q Exits, if the buffer has been modified, it will prompt
: q! Force quit, discard modifications
Find replacements
/pattern Backward Search string pattern
? pattern searches forward string pattern
N Next match (if yes/search, then down next,? Search is up next)
N previous match (IBID.)
:%s/old/new/g Search entire file, replace all old with new
:%S/OLD/NEW/GC searches the entire file, replaces all old with new, and each time you confirm whether to replace
Copy and paste
DD deletes the cursor in the row
DW Delete one word (word)
X Delete Current character
X Delete the previous character
D Delete to end of line
YY copy a row, this command can be followed by a number, identity copy multiple lines, such as 6yy, to start copying 6 rows from the current line
YW copy a word
y$ Copy to end of line
P Paste the contents of the clipboard below the current line
P Paste the Clipboard contents to the top of the current line
]p with indented paste, Vim automatically adjusts the indentation of the Code
"A registers content in/into a register, can support multiple pasteboard
Attached: For example, a commonly used register is the system register, the name is +, so from the system pasteboard paste into Vim command for "+p, note here the + does not represent the operator, 21 registers."
Move cursor
Moving the cursor in VIM is very different from other editors, but once learned, it moves quickly in the text.
H,j,k,l, down, left, right.
Ctrl-f up a page
Ctrl-b down one page
% jumps to the parentheses that match the current bracket, as currently in {, jumps to the matching}
W Jump to the next word, split by punctuation or word
W jumps to the next word, long jump, as end-of-line is considered a word
e jumps to the end of the next word
E jump to the end of the next word, long jump
b jumps to the previous word
B jump to the last word, long jump
0 jumps to the beginning of the line, whether or not indented, jumps to the No. 0 character
^ Jumps to the first character of the beginning of a line
$ jump to end of line
GG jumps to the first line of the file
GD jumps to the declaration of the variable at which the cursor is currently located
N G jumps to the nth row, such as 0G, equivalent to gg,100g is the 100th row
FX finds the X character in the current line and jumps to
; Repeat the previous F command without repeating the input FX
TX is similar to FX, but only jumps to the previous character of X
FX and FX are in the opposite direction
), (jump to upper/Next statement
* Find the word where the cursor is located and look down
# Find the word where the cursor is located, look up
`. Jump to last edit location
Move on the screen
H move the cursor to the top line on the current screen
M moves the cursor to the middle line on the current screen
L move the cursor to the bottom line on the current screen
Bookmark
Ma saves the current position as a label
' A jumps to label a
Edit
R replaces one character
J connect the next line and the current row as a row
CC Deletes the current line and enters edit mode
CW Deletes the current word and enters edit mode
C $ erases content from the current position to the end of the line and enters edit mode
s delete the current character and enter edit mode
S Delete the line of the cursor and enter edit mode
XP swaps the current character and the next character
U undo
Ctrl+r Redo
. Repeat last Edit command
~ Toggle case, current character
G~IW Toggle the case of the current word
GUIW the current word into uppercase
GUIW the current word into lowercase
>> move the current line one unit to the right
<< moves the current line one unit to the left (one tab character)
= = automatically indent as you go forward
Insert mode
I enter insert mode from the current cursor
I go into insert mode and place the cursor at the beginning of the line
A append mode, with the cursor positioned after the current cursor
A Append mode with cursor at end of line
o Add a new line below the current line and enter insert mode
O add a new line above the current line and enter insert mode
ESC exits insert mode
Visual mode
Tag text
V Enter visual mode, single character mode
V Enter visual mode, line mode
CTRL + V enters visual mode, column mode, similar to UE's column mode
o Jump cursor to another endpoint of the selected block
U turn the contents of the selected block into uppercase
O jump cursor to another endpoint of the block
AW Select a Word
AB selects everything in parentheses, including the parentheses themselves
AB selects all contents of {} brackets
IB selects the bracketed content without parentheses
IB selects the contents of {} without {}
To act on a marker
> Block Right Shift
< block shift Left
Y copy block
D Delete Block
~ Case of content in toggle block

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.