VIM has six modes (but commonly used on three kinds of normal, insert, command line)
?
?
?
Normal mode
??? In normal mode, the editor commands, such as moving the cursor, deleting text, and so on. This is also the default mode after Vim is started. This is exactly the opposite of what many new users expect (most editor default mode is insert mode).
?
?
?? Vim's powerful editor can come from its normal mode commands. Normal mode commands often require an operator end. For example, the normal mode command DD deletes the current line, but the first "D" can be followed by a different move command instead of the second d, such as the "J" Key moved to the next line to delete the current row and the next row. You can also specify the number of commands to repeat, 2DD (repeat DD two times), and the DJ's effect is the same. Users learn a variety of text between the move/jump commands and other common mode of editing commands, and can be used flexibly combined, can be more efficient than those without the pattern of the editor for text editing.
In normal mode, there are many ways to get into insert mode. The more common way is to press a (append/append) key or I (insert/insert) key.
?
Insertion modes (insert mode)
?? In this mode, most keystrokes insert text into the text buffer. Most new users want this mode to persist throughout the text editor editing process.
?? In insert mode, you can press the ESC key back to normal mode.
??
?
Visual modes (visual mode)
? ????? This pattern is similar to normal mode. However, the move command expands the highlighted text area. The highlighted area can be a character, a line, or a piece of text. When a non-moving command is executed, the command is executed to the highlighted area. Vim's "text object" can also be used in this mode as the move command.
?
?
?
Selection mode (select modes)
??? This pattern is similar to the behavior of the modeless editor (the way Windows standard text controls are). In this mode, you can use the mouse or cursor keys to highlight the selection of text, but the input of any character, Vim will use this character to replace the selected highlighted text block, and automatically enter the insertion mode.
?
?
?
Command line mode
???? In command-line mode, you can enter text that will be interpreted and executed. For example, execute commands (: keys), search (/and keys) or filter commands (! Key). After the command is executed, VIM returns to the pattern before the command-line mode, usually in normal mode.
??
?
?
Ex modes (ex mode)
??? This is similar to command-line mode, where you can execute multiple commands at one time before using the: Visual command to leave the ex mode.
?
?
?
?
Three commonly used modes
Vim boot into normal mode, normal mode press I or a can enter the insertion mode: Enter the command line mode.
Insert mode--------> Command mode
Esc
Command mode--------> Extended command mode
:
Extended Command mode--------> Command mode
Esc,enter
?
?
?
Vim can be followed by either the existing file you want to open or the name of the file that needs to be created.
Vim XXXX
?
?
?
In normal mode,
H is left, L right, J down, K on
W moves to the next with a space symbol carriage return, etc.
?
?
When entering insert mode
I edit at the current cursor
I Insert at the beginning of the line
A inserts at the end of A row
A inserts an edit after the cursor
o Insert a new row after the current line
O insert a new row before the current line
CW replaces the character (??) from the position of the cursor to the end of a word. Have the feeling that the verification can't use??? )
?
?
?
Save the document in command-line mode or save to exit vim
Input from Normal mode: Enter command line mode, enter W and return to save the document.
or enter a W file name to save the document as a different file name, or to save it to a different path
?
?
?
Enter WQ in command-line mode to save and exit vim
Q! : Force quit, do not save
Q: Exit
qw! : Force Save and exit
W: Save As
SaveAs: Save As
X Save exit
Wq Save exit
?
?
?
Out of vim in normal mode
Input Shtift +zz to save the proposed vim
?
?
Delete Vim text information in normal mode
X: Delete the character where the cursor is located
X: Delete the previous character of the cursor
Delete with X
DD: Delete entire row
DW: Delete a word (not in Chinese)
d^: Delete to beginning of line
DG: Delete to end of document
D1G: Delete to document header
?
In addition, add a number to the command before you can delete multiple lines:
For example 2DD can delete 2 rows
?
?
?
Extended mode: Current VIM process is valid
? (1) Line number
Display: Set number, abbreviated as set Nu
Cancel display: Set Nonumber, abbreviated to set Nonu
? (2) Case of ignoring characters
Enable: Set IC
Do not ignore: set Noic
? (3) Auto Indent
Enable: Set AI
Disabled: Set Noai
(4) Smart indent
Enabled: Smartindent shorthand set Si
Disabled: Set Nosi
? (5) Highlight Search
Enabled: Set Hlsearch
Disabled: Set Nohlsearch
? (6) syntax highlighting
Enabled: Syntax on
Disabled: Syntax off
? (7) Display tab and line break ^i and display
Enabled: Set list
Disabled: Set Nolist
? (8) file format
Enable Windows format: Set Fileformat=dos
Enable UNIX format: set Fileformat=unix
Shorthand: Set Ff=dos|unix
? (9) Set text width
Enabled: Set textwidth=65 (VIM only)
Disabled: Set wrapmargin=15
? (10) Set the identification line of the line where the cursor is located
Enabled: Set Cursorline, abbreviated CUL
Disabled: Set no Cursorline
? (11) Copy retention format
Enabled: Set paste
Disabled: Set Nopaste
?
?
?
Vim Configuration file Location:
Configuration file: Permanently valid
Global:/ETC/VIMRC
Personal: ~/.VIMRC
?
?
?
Vi/vim built-in Help
: Help
: Help Topic
Use:q to exit Help
?
-----------------Split Line------------------------
?
Document editing
??
?
In normal mode. (decimal point) means repeating the last command operation
For example:
In normal mode, enter X to delete the first character, enter. (decimal point) will delete one character again, and you can repeat the delete operation of DD.
?
?
Inline jump
NG cursor moves to nth row (supplemental: Enter command mode input: Set Nu to show line numbers)
?
GG cursor moves to the first row
G move to last line
?
?
?
In-line jump
W to the beginning of the next word
E to the end of the next word a
B to the beginning of a previous word
GE to the end of the previous word
0 or ^ to the wardrobe
$ to end of line
f< Letters > backwards search < letters > and jumps to the first matching position (five star)
f< Letters > forward Search < letters > and jumps to the first matching position
t< Letters > Backward Search < letters > and jumps to a letter before the first matching position (not commonly used)
t< Letters > forward Search < letters > and jumps to the first letter after the first matching position (not used)
?
?
Copy, paste text
Use Y to copy in normal mode
?
?
In normal mode
yy the entire row where the copy cursor is located (3yy means copy 3 rows)
y^ copied to the beginning of the line. Or y0 does not contain the character of the cursor
y$ copied to the end of the line. Contains the character of the cursor
YW copy a word
y2w copy Two words
YG Copy to end of text
Y1G Copy to beginning of text
?
P represents paste to Cursor
P (uppercase) represents the paste to the front of the cursor
?
?
Replace and REVOKE commands
For operations in normal mode
?
r+< to replace letter > replace cursor with specified letter
R is continuously replaced until ESC is pressed
CC replaces the entire row, which deletes the row with the detailed cursor and enters insert mode
CW replaces a word,
C (uppercase) Replace the cursor to the end of the line
~ Reverses the case of the cursor in the same letter
U{n} Undo once or N operations
U (uppercase) undo all changes to the current line
Ctrl+r Redo, undo undo action
?
?
Fast Indent
Enter in normal mode
?
15G: Jump To line 15
(>>): The entire line is indented to the right
(<<): Full line left-backward
(:) "" Enter command line mode to set the Shiiftwidth value to control the number of indents and fallback characters
?
?
?
Shifwidth command
The shiftwidth command refers to the indentation (which can be abbreviated to SW) generated by the previous section >> command input in normal mode: Enter the command line mode to set the Shiftwidth value to control the number of characters in the indent and fallback to get the current set value
?
?
?
Quick Find
Enter in normal mode * Find the word where the cursor is located
Normal mode input # Same, but # is forward (up) to find, * is backward (bottom) to find
Normal Mode input g* *, but partially conform to the word can be
In normal mode, enter g# with #, but partially conform to the word
?
?
Important
CTRL +s the VIM in suspended animation
CTRL +q to make VIM resume in the state of suspended animation
VIM Basics Beginner for personal use