11.vim common operations

: set nu
show line numbers in command mode

The input mode is
new (the append)
A: Start from the new data location after the cursor, the cursor data with the new data after the backward movement.
A: From the column where the cursor rearmost start adding information.
 
Insert (INSERT)
I: Information inserted starting from the front of the cursor position, the cursor data with the new data after the backward movement.
I: insert data start from the front of the first non-blank character cursor column.
 
Start (Open)
O: Add a cursor in the column and the input mode.
O: Add a cursor over the column and the input mode.
 
Exit vi
in command mode, type: q,: q,:! Wq or: x (Note: No), will exit vi. Where: wq and: x is save and exit, and: q is the exit, if the file has new changes, vi will prompt you to save files: q command will fail, then you can use: w command to save the file and then: q to exit, or use: wq or: x command to exit the file if you do not want to save the changes, you will need to use:! q command, which will not save the file and exit vi.
 
Delete and modify the command file:
the X-: delete character under the cursor.
dd: delete the column the cursor.
r: Modify the character under the cursor, then after r character to be corrected.
R: Take into the replacement state, add text to overwrite the previous text, until [ESC] to return to the command mode so far.
s: delete character under the cursor, and enters input mode.
S: delete the column cursor, and enters input mode.

Screen roll commands of
Ctrl + u: the file header turn half screen
Ctrl + d: Total half screen to the end of the file
Ctrl + f: turning a screen to the end of the file
Ctrl + b: the beginning of the file down one screen
nz: the rolling line n to top of the screen, when you do not specify n roll to the current line to the top of the screen.

Delete command
ndw or ndW: Remove the cursor at the beginning and after the word n-1
do: to delete the first row
d $: Delete to end of line
ndd: delete the current line after the row n-1 and
x or X: delete a character, x deleted after the cursor, while the cursor in front of the X delete
Ctrl + u: delete input mode at the input text

Search and Replace command
/ pattern: from the cursor at the beginning of the search pattern to the end of the file
pattern:? From the cursor at the beginning of the first search pattern to the file
n: repeat in the same direction a search command
N: repeat in the reverse direction a search command
: s / p1 / p2 / g: the current line all p1 are replaced by p2
: n1, N2S / p1 / p2 / g: the first n1 to n2 rows all p1 are used p2 alternative
:% s / p1 / p2 / g : All files are replaced with p1 p2

Copy, paste
(1) selected text block, v enter visual mode; selection keys to move the cursor
(2) to copy the selected block buffer, with Y; copy the whole line, with YY
(. 3) cut selected block to the buffer, with D; the whole line with shearing dd
(. 4) to paste the contents of the buffer, with p

Guess you like

Origin www.cnblogs.com/allenhu320/p/11284307.html