Vim Command Collation

Source: Internet
Author: User

1. File command 2. Mode Switch 3. Move Command 4. Bookmark Command 5. Modify Command 6. Visualization Operation 7. Region Selection 8. Macro Command 9. Split screen 10. System Setup Command 1. File command [:] Start command requires input [Enter] End: Q: Exit: q!: Exit does not save: qa!: Quit all files do not save: w: Save: E <file>: Close the current file and open another file: SaveAs <file>: Save As <file>: Wq or: X or ZZ: Save and exit (ZZ does not need a colon [:]): bn or: N: When you open multiple files, switch to the next file: BP: Multiple files, switch to previous file sudo permissions force write:: w!sudo Tee% (!sudo- Execute shell Command Sudo,tee-will: w result redirect,%-current file): Help <command>: Show command assist:!&LT;COMMAND&GT;: Execute a shell command: Bash:A shell is shipped without exiting VI. Exit command back to Vim:[n]: a colon followed by a number to indicate to the first line, if followed by 1, represents to the file header, if with $, expressed to the end of the file Ctrl+g: can display the current line in the entire file percentage of 2. Mode Toggle 2.1 Normal Mode to insert mode I: Inserts to the left of the current character
I: Inserting at the beginning of the current line
A: Insert to the right of the current character
A: Insert at the end of the current line
o: Insert a new row below the current line
O: Insert a new line above the current line <c-v>c: Enter special characters ^c<c-p> or &LT;C-N&GT;: auto-fill 2.2 insert mode to normal mode [ESC]3. Move CommandsN<command>: Repeat a move or modify a command N timesH, J, K, L: Left, bottom, top, right Move G[h, J, K, L]: Lets move the number of rows relative to the screen rather than the number of rows inside the vim3.1 In-line movementW: Move to the beginning of the next worde: Move to the end of the next wordB: Move to the beginning of the previous word w/e/b: words are separated by a space when moved, and the default contains only letters, numbers, and underscores
0: Move to the beginning of the current line
^: Move to the first non-empty character of the current line
$: Move to end of line g_: Move to the first non-empty character at the end of the current line
): Move the cursor to the next sentence, using the period [.] or line break delimited
(: Move the cursor to the previous sentence, using the period [.] Or newline delimited 3.2 files within the moveG: To end of fileN G: Move the cursor to the specified line (n). (e.g. 10G is to line 10th)
GG: To the top of the file H: Move the cursor to the top of the screen
M: Move the cursor to the middle of the screen
L: Move the cursor to the bottom of the screen <c-f>: Move down one screen
<c-b&gt: Move up one screen 3.3 find and move in-line lookups using [;] Repeat the previous f/t/f/t command FX: Moves the cursor to the next X in the current line. X can be any one letter, and you can
TX: Similar to the above command, but moves to the left of X (this is really useful)
FX: Similar to FX, but back to TX: Similar to TX, looking back to the right of the x to find inside a file%: Jump to paired parentheses[[: Jumps to the beginning of the code block (but requires that ' {' In the code block must be a separate line)" : Jumps to the beginning of the last docked position of the cursor at the start of the letter, is two ', not a"
*: Reads the string at the cursor and moves the cursor to where it appears again. Repeat search press [n]
#: Similar to the above, but looking in the opposite direction. Repeat search Press [N]GD or GD: jumps to the definition of the local variable (or arbitrary string) where the cursor is located
/text: Searches for the string text from the current cursor and reaches the text where it appears. Repeat search press [n]
? Text: Similar to the above, but in the opposite direction 4. Bookmark Command MA: Marks a bookmark at the position of the current cursor, named A. The book signature can only be lowercase letters. You can't see the existence of a bookmark, but it's already there.
' A: Go to bookmark A. Note that this is not a single quote, it is generally on the left side of 1 of most keyboards.
'.: To the place where you last edited the file. This command is useful, and you don't have to tag it yourself. 5. Modify the command.: Repeat the last modification command N<command>: Repeat one move or modify the command n times, and repeat other commands, such as 10iza[esc], to indicate that you have repeatedly inserted the za 10 times. U: Undo Last Modified U: Undo all modifications of the current line <c-r>: Redo the last modified 5.1 format control &GT;&GT;: Increase Indent, "x>>" to increase indentation <&lt for the following x lines;: Reduce indentation, "x<< "Indicates that the next row and the current line are reduced by indenting the following x lines: J 5.2 Cut (delete), copy, paste *motion can be any move command, such as ^, $, G, W, fx* clipboard (also called Register [Register]), [: Reg] Lists the registers and contents in use, using" Ayy Copy the current row to register a, use the AP to paste the contents of register a D{motion}: Cut to cut the motion "brushed" text to the Clipboard C{motion} : Cut and enter insert mode DD: Cut the current row cc: Cut the current row and go into insert mode D: Cut the current position of the cursor to the end of the line, similar to [d$]c: Cut the current position of the cursor to the end of the line and into insert mode, similar to [c$]x: clipping the current character. (BACKSPACE) (similar to command mode) s: Cuts the current character and enters insert mode
Y{motion}: Copy, Ibid. yy: Copy the current line to the Clipboard y: Copy the line to the Clipboard, similar to [YY] P: Paste to the current position after P: Paste before the current position]p: similar to P, but automatically adjusts the indentation]p of the pasted code: similar to P, but automatically adjusts the indentation of the pasted code 5.3 Find Replacements:%s/word1/word2/g: Full-Text search word1 and replaced with Word2: [n],[m]s/word1/word2/g: When searching and replacing a string lookup between lines A and B only, "\ n" is a newline, "\ R" is a carriage return, Which is often seen in the ^m. When a string is replaced, "\ r" is a newline, ' \ n ' is a null character (0x00) to delete the empty line: G/^\s*$/d6. Visual Action Select text V: Character selection
V: Line Selection
<c-v>: Block selection, you can select any rectangular block operation d/c/y: delete or copy gu or gu: full change lowercase or uppercase J: Connect all lines > or <: indent =: Auto Indent instance ^ Select Ixx[esc]: Start line insertion Select Ixx[esc] : Block before inserting XX Select Axx[esc]: Block End insert XX Select $ Axx[esc]: End of line insert 7. Region selection <action> [n] a/i <object>: Select N-heavy content within the target range of object, such as words, sentences, parentheses (), []<action>:d-Delete, y-Copy, V-Visual selection A/ I:a-Contains object,i-does not contain object<object>:w-word, w-space-delimited word, s-sentence, p-paragraph, "/'/"/}/]-brackets or quotation marks 8. Macro command QA: Start recording macro and save in register [a]
Q: End Recording
@a: Replay macro @@: Register A: Play back the latest macro instance qayp<c-a>q [email protected]@: Turn 1 Lines "1" into 101-line sequence of numbers: 1\r 2\r 3\r ... 1019. Split screen vim-on file1 file2 ... : Open several files, and vertical split screen vim-on file1 file2 ... : Open several files and split horizontally: New: Create blank horizontal split screen: Vsplit (: VSP) <file>: Create vertical split screen and open file <file>, default file: Sp (split) <file> : Create a horizontal split screen, and open the file <file>, the default is that the current file is basically <C-W> and then add a key letter, triggering a function <C-W> c/q or: Q: Close the current Window <C-W> o or: o Nly: Close all other Windows <C-W> s/v: Horizontal/Vertical Split screen current file <C-W> h/j/k/l: Move cursor to left/bottom/top/Right split screen <C-W> W: Move cursor to order next split screen <C-W> h/ J/K/L: Move split screen to left/bottom/top/Right<C-W> =: All split-screen sizes are equal<C-W> +/-: Increase/decrease split screen height<C-W> >/<: Increase/Decrease split screen width10. SystemSET CommandUse the [: Set XXX] setting in normal mode to turn it off using [: Set noxxx], or write in the ~/.VIMRC file (no colon [:] in the file)syntax EnableSyntax onset IC "ignore case (ignore case) set Noic" Do not ignore casing set Nu "Display line number set Hlsea Tc.set Expandtab "Setting tabSet shiftwidth=4 "Setting tab interval
Set ts=4 "Four spaces represents a tab (TabStop) set AI" set auto Indent (autoindent) Set ls=2 "always displays the file name ( can also be used ctrl+g or: f)

Vim Command Collation

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.