Http://homepage.ttu.edu.tw/u9106240/page_main/vim_menu.html
Enter input mode
Enter the following instruction in command mode, and the program will enter the input (insert) mode
The user can then modify the file,
If you want to jump out of the input mode, you can go back to command mode by entering <ESC>.
I
Enter input mode to the left of the cursor
I
Enter the input mode at the beginning of the line where Rengpui is located
A
Enter the input mode to the right of the cursor
A
Enter input mode at end of line of RENGPUI
O (write English letter O)
Start a new row on the next line in the cursor and enter the input mode
O (write English letter O)
Start a new row on the cursor line and enter the input mode
Back to the top end
§ Moving the cursor
K
Move the cursor up one character
Which is the key "↑".
J
Move the cursor down one character
Which is the key "↓".
H
Move cursor one character to the left
Which is the key "←".
L
Move the cursor one character to the right
Which is the key "→".
H
Move the cursor to the top of the screen
M
Move the cursor to the center of the screen
L
Move the cursor to the bottom of the screen
: Numbers
Move the cursor to the first number line of the file
If input: 45, move to file line 45th
Digit G
Move the cursor to the first number line of the file
If you enter 45G, move to file line 45th
Gg
Move the cursor to the first line of the file
G
Move the cursor to the last line of the file
B
Move the cursor to the first letter of the word
If it is already the first letter of the word, the cursor moves to the first letter of the previous single word.
E
Move the cursor to the last letter of the word
If this is the last letter of the word, the cursor moves to the last letter of the next single word.
W
Move the cursor to the first letter of the next single word
^
Move the cursor to the first non-white-space letter of the line
Back to the top end
Scroll window
<ctrl>+f
Scroll the window down half
<ctrl>+b
Scroll the window up half
<ctrl>+d
Scroll the window down a page
<PageDown> in functional-like keyboard
<ctrl>+u
Scroll the window up a page
<PageUp> in functional-like keyboard
Back to the top end
Search text
/String
Search the string down
Following this order, if the file contains that "string", the background color of all "strings" in the file is replaced with a more vivid color, and after the search instruction is completed, the "n" and "n" instructions can be used to control it.
N jumps to the next "string" location
N jumps to the previous "string" Location
In addition, stop the cursor on the string you want to search, and press "*" to reach the search results.
? string
Search up a string
Following this order, if the file contains that "string", the background color of all "strings" in the file is replaced with a more vivid color, and after the search instruction is completed, the "n" and "n" instructions can be used to control it.
n jumps to the previous "string" Location
N jumps to the next "string" location
In addition, stop the cursor on the string that you want to search, and press "#" to reach the effect of searching upwards.
Back to the top end
Copy, move, delete text
Yy
Copy that line of text
Directive Y has the same function
P
Paste the clipped or copied text
Row number 1, row number 2 Co row number 3
Copy all characters from row number 1 to row number 2 to row number 3
※ Note: line number 3 must exist, otherwise this command will be ineffective.
For example: Original document:
This is Line 1. This is Line 2. This is Line 3.
Input instruction: 1, 3 CO 3 will become
This is Line 1. This is Line 2. This is Line 3. This is Line 1. This is Line 2. This is Line 3.
<BackSpace> (used in input mode)
Delete a text from the left side of the cursor
Dd
Remove the line of text
This instruction can be used in conjunction with the instruction P (paste)
and become a "cut" function.
Dw
Delete the word
Cc
To change the line of text
When this instruction is entered, the RENGPUI is erased and automatically enters the input mode.
cw
Change the word
When this instruction is entered, the character of the word after the cursor is removed and automatically enters the input mode.
D
Erase all text on the right side of the line where the cursor is located
<CTRL>+W (in input mode)
Remove all characters from the left side of the single word in the cursor
Row number 1, row number 2 m row number 3
Move all the characters from row number 1 to row number 2 to row number 3
※ Note: line number 3 must exist, otherwise this command will be ineffective.
For example: Original document:
This is Line 1. This is Line 2. This is Line 3. This is line 4. This is line 5. This is line 6.
Input instruction: 1, 3 M 6, and then it becomes
This is line 4. This is line 5. This is line 6. This is Line 1. This is Line 2. This is Line 3.
Row number 1, row number 2 D
Delete all characters between rows 1 and 2
For example: Original document:
This is Line 1. This is Line 2. This is Line 3. This is line 4. This is line 5. This is line 6.
Input instruction: 2, 4 D then it will become
This is Line 1. This is line 5. This is line 6.
: g/replaced string/s//new string/g
Replace "substituted string" with "new string"
For example: Original document:
That's line 1. That's Line 2. That's line 3. That's line 4. That's line 5. That's line 6.
Input instruction: After g/is/s//is not/g, it becomes
That isn't line 1. That isn't line 2. That isn't line 3. That isn't line 4. That isn't line 5. That isn't line 6.
Back to the top end
§ Access files & VI programs
: Q
Leave the VI program without saving modifications
If you do not have any changes to the file, use: Q can be jumped out,
But if you modify the contents of the file you must use: q! Instructions can be successfully stored out of the store.
: q!
Leave the VI program without saving modifications
: W
Save the currently edited file
: W file name
Save the current edited file to the "filename"
: Wq
Save the currently edited file and leave the VI program
: X
Save the currently edited file and leave the VI program
Function and: Wq the same.
Back to the top end
§ Other Directives
U
The motion is still original
If you do not take care of the wrong instructions, you can use this instruction to the original.
K
The function of inquiry
If you write in VIM, you can use the C/C + + standard function 厙 The function name provided by pressing "k", you can call out the man page to inquire about the usage of the function
=
Auto program shrink Align
If you write a C + + program in VIM, you can use the "gg" instruction to move the cursor to the top of the window, using "v" switching to selection mode, and then using "g" to move the cursor to the end of the file (that is, to the full selection feature), the last press "=",vim will help your program do it automatically.
<ctrl>+r
To redo a motion.
If you are not careful, you can use this instruction to redo.
: Set All
Shows all parameters
All of the parameters of VIM support can be traced through this instruction.
If you set the parameters in the way that you perform the VIM program, through the ":set parameters, each time you open a VIM program, you have to reset it again, and if you want vim to be able to download the user's settings every time it is started, you can create a name for the user's home. vimrc"'s file to store a personal VIM setting.
For example: To establish a file "vi/home/kevin/.vimrc", file:
Set Background=dark set autoindent set number in this setting, the first line indicates that the color of the character is suitable for the black background, and the second line is to open the auto-zoom function, and the third line to open the Display line function
: Set Nu
Display row numbers
If you want to know the line number of the file, you can get this instruction.
: Set Nonu
Hidden Line Numbers
If you want to hide the line number of the file, you can reach this command.
: Set Autoindent
Self-shrinking function
After you have opened this feature, pressing the Enter button creates a new line that copies the tab and space numbers in front of the previous line to achieve your goal. This feature can be closed through ":set noautoindent"
: Set tabstop= numbers
Set tab-Align characters
In the general VIM setting, TabStop's preset is 8, but under Windows, a number of text editing software's preset tabstop is 4, and if you want to change Vim's tab number to 4, you can move to ":set in Vim's command mode TabStop =4"directives
: Set background= mode
Set the keyword character color mode
Using the ":set background=dark" instruction allows the keyword in VIM to appear in a brighter color, suitable for dark color backgrounds. Using the ":set background=light" instruction allows the keyword in VIM to appear in a darker color, suitable for the background of a bright light system.
: Split [file name]
Horizontal Split Text edit window
In the case of a designated "file name", the new window opens the file; If not specified, the new window will still open the original file.
In addition, you can use the <ctrl>+w in the edit window to select the desired editing window with the arrow keys.
If you want to close the window, in a command mode that closes the window,
Enter the leave instruction, such as:: Wq can close the window.
: vsplit [file name]
Vertical Split text editing window
In the case of a designated "file name", the new window opens the file; If not specified, the new window will still open the original file.
In addition, you can use the <ctrl>+w in the edit window to select the desired editing window with the arrow keys.
If you want to close the window, in a command mode that closes the window,
Enter the leave instruction, such as:: Wq can close the window.