1,CTR-C enters the command line,
2. Press dd => to delete the row where the cursor is located.
3. Press A => to enter the insert mode.
Gvim Basic commands
Editing mode |
Command |
Description |
Enter insert mode |
I |
Insert text before the cursor position |
I |
Move the cursor to the beginning of the current row and insert text before it |
A |
Used to append new text after the cursor's current position |
A |
Move the cursor to the end of the row and insert new text there |
O |
Open a new line under the row where the cursor is located, place the cursor at the beginning of the line, and wait for the input text |
O |
Insert a line above the row where the cursor is located, place the cursor at the beginning of the line, and wait for the input text |
Cursor Positioning |
G |
Move the cursor to the last line of the file |
Replacement and Deletion |
RC |
Replace the cursor prefix with character C |
NRC |
Use character C to replace the first n characters pointed to by the cursor |
X |
Delete characters at the cursor |
NX |
Delete n characters from the cursor position to the right |
DW |
Delete a word. If the cursor is in the middle of a word, it is deleted from the cursor position to the end of the word with spaces |
Ndw |
Delete n specified words |
DB |
Delete a word before the cursor position |
NDB |
Delete n words before the cursor position |
Dd |
Delete current row |
NDD |
Delete the content of the current row and the following n-1 rows |
Copy and paste |
YY |
Copy the content of the current row to the buffer zone |
Nyy |
Copy the starting n rows to the buffer zone. |
P |
Write the content of the buffer zone to the location of the guangcun |
|
/Str |
Move to the place where STR exists to the right |
? Str |
Move to the place where STR exists to the left |
N |
Move to a place with str in the Same Direction |
N |
Move to a place with str in the opposite direction |
Undo and repeat |
U |
Cancel previous misoperations |
. |
Execute another complex command just completed. |
Exit |
Zz |
Save disk and exit |
ZQ |
Do not save and exit |
In command line mode |
Command |
Description |
Skip |
: N |
Jump to row n |
Exit |
: Q |
Exit vi |
: WQ |
Save and exit vi |
: Q! |
Exit VI without saving |
File-related |
: W |
Save the currently edited content to the disk |
: W File |
Write the edited content to the file. |
: N1, n2w File |
Write the row from N1 to N2 to the file. |
: NW File |
Write row n to file |
: 1,. W File |
Write all content from the first line to the cursor position to the file. |
:., $ W File |
Write all content from the current position of the cursor to the end of the file to the file. |
: R File |
Open another file |
: E File |
Create another file |
: F File |
Rename the current file as a file |
String search, replacement, and deletion |
:/Str/ |
Move from the current cursor to the place where STR exists |
Str? |
Move from the current cursor to the left where STR exists |
:/Str/W File |
Write the row containing STR to the file. |
:/Str1/,/str2/W File |
Write the content from str1 to str2 to the file. |
: S/str1/str2/ |
Replace the first str1 with str2 |
: S/str1/str2/g |
Replace all str1 with str2 |
:., $ S/str1/str2/g |
Replace all str1 from the current position to the end with str2 |
Copy, move, and delete text |
: N1, N2 Co N3 |
Copy the content from line N1 to line N2 to the end of line N3. |
: N1, N2 M N3 |
Move the content from line N1 to line N2 to the end of line N3. |
: D |
Delete current row |
: Nd |
Delete n rows starting from the current row |
: N1, N2 d |
Delete all content from row N1 to row N2 |
:., $ D |
Deletes all content starting from the current row to the end. |
:/Str1/,/str2/d |
Delete all content starting from str1 to str2 |
Execute Shell Command |
:! Ls |
Run the shell command ls (here ls can be replaced with other commands) |
N1, N2 W! Command |
Input the content from line N1 to line N2 as the command. If N1 and N2 are not specified, the content of the entire file is used as a command. Command Input |
: R! Ls |
Write the result of running the LS command to the location of the current line (here ls can be replaced by other commands) Http://blog.sina.com.cn/s/blog_4e95dba90100g4dz.html |