Vi editor common command memos

Source: Internet
Author: User
Switch to input mode:
A: Enter text after the cursor position.
A: Enter text at the end of the row where the cursor is located.
I: insert text from the front of the cursor.
I: insert text before the first non-space character in the row where the cursor is located.
O: Add a column below the row where the cursor is located and enter the input mode.
O: Add a column above the row where the cursor is located and enter the input mode.
H: shifts the column to the left.
J: move down a row.
K: Move up a row.
L: Shift one column to the right.
/Str: Search for str
N: Search for the next one in the current direction.
N: searches for the next one in the reverse direction of the current query.
W: move the cursor to the beginning of the next word.
B: move the cursor to the beginning of the previous word.
E: move the cursor to the end of the next word.
$: Move the cursor to the end of the current row.
^ Or 0: move the cursor to the beginning of the current row.
Fm: move the cursor to the next character m of the text.
NG: move the cursor to line n.
G: move the cursor to the last row.
-: Move the cursor over the current row.
+: Move the cursor to the next row of the current row.
: N: move the cursor to line n.
: $: Move the cursor to the last row.
L: move the cursor to the bottom of the screen.
M: move the cursor to the middle line of the screen.
H: move the cursor to the top row of the screen.
'': The cursor returns to the original position. (One pair of single quotes)
X: delete a character at the cursor.
Nx: delete n characters at the cursor.
Dd: Delete the current row.
10dd: Delete the 10 rows starting from the current row.
Dw: delete a word at the cursor.
Df/: delete all characters from the cursor to the first character.
: 5d: delete 5th lines of text.
: 5, 10 days: delete text lines from 5th to 10.
: 10, $ d: delete from row 10th to the end of the row.
U: cancels the last operation.
U: undo all modifications made to the current row, provided that the cursor is not removed from the current row.
.: Repeat the last text modification command. (English end)
J: concatenate two lines of text.
R: Replace the character at the current cursor.
R: Replace the text behind the cursor by character.
S: replace one character at the current cursor with multiple characters.
Cw: replace a word at the current cursor with multiple words.
Cc: Replace the current row.
Cfm: replaces the part from the cursor to the character m.
C: Replace the cursor with the end of the line.
: S/str1/str2: Replace the first str1 in each line in the text with str2.
: S1, 10 s/str1/str2: Replace the first str1 in each line from 1 to 10 with str2.
: G/var/s/str1/str2: Replace the first str1 in the row containing var WITH str2.
: 1, $ s/bin/BIN/g: Replace the bin in the entire file with BIN (not the first in each line ).
Yy: copy the current row to the buffer zone of vi.
P: paste the copied row to the previous row of the row where the cursor is located.
P: paste the copied row to the next row of the row where the cursor is located.
DDP: the upper and lower rows are exchanged.
YW: copy the current word.
YL: copy the current character.
Yfm: copy the text between the current cursor and the first M character.
: 7 copy 10: Copy 7th rows of text to the end of 10th rows.
: 7th copy $: copy the text from lines 9th to lines to the end of the file.
:., 15 copy 3: copy the contents of the current row to the end of the third row.
(. Indicates the current row, $ indicates the end of the file, and 0 indicates the beginning of the file)
: 7 move 10: Move 7th lines of text to the end of 10th lines.
: W: Save the file.
: X: Save and exit. It is equal to the command: WQ.
: W file: Save the current file to the file.
: 10th Write File: Save the contents of lines 15th to the file.
: 10, 15 Write! File: Write lines 10th to 15th to existing files and forcibly overwrite them.
: 10th write> file: append lines to 15 to the end of the file.
: 1 read file: Read the file content to the second and second lines of the current file.
:! CMD: Start a sub-shell and execute the command cmd.
: Read! CMD: Read the command cmd output to the current line of the current file.
: 0 read! Cmd: Read the command output to the beginning of the current file.

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.