Common VI editor command line

Source: Internet
Author: User
Link: http://www.cnblogs.com/junw_china/articles/1708967.html

For the command line of Vi, you do not need to remember it. Write it down so that you can find it when using it.

Cursor control

H Move the cursor to the left
J Move the cursor downward
K Move cursor up
L (or spacebar) Move the cursor to the right
W Move a word forward
B Move one word backward
E Move a word forward and the cursor points to the end of the word
( Move to the beginning of the current sentence
) Move to the beginning of the next sentence
{ Move to the header of the current segment
} Move to the first part of the next section
[[ Move to the beginning of the current section
] Move to the first part of the next section
0 Move to the header of the current row
$ Move to the end of the current row
^ Move to the first non-blank character in the current line
+ Or return Move to the first character of the next line
- Move to the first character of the previous line
N| Move to the place where the CHARACTER n of the current row
H Move to the front of the current screen
M Move to the center of the current screen
L Move to the end of the current screen
NH Move to N rows at the beginning of the current screen
NL Move n rows to the end of the current screen
CTRL-F Move to the next Screen
CTRL-B Move to the previous screen
CTRL-d Move the half screen downward
CTRL-u Move up half screen
   
   
Z return Refresh the screen and adjust the screen so that the current cursor is at the first part of the refreshed screen (do you not understand ??? If you don't understand it, try to know what it means)
Z. Refresh the screen and adjust the screen so that the current cursor is in the center of the refreshed Screen
Z- Refresh the screen and adjust the screen so that the current cursor is at the end of the refreshed Screen
CTRL-l Refresh the screen without adjusting the screen position
CTRL-R Refresh the screen without adjusting the screen position
/Text Search down text
/ Repeat the content of the previous search and perform a downward search.
?Text Search up text
? Repeat the search content to search up once
N Repeat this search and search down
N Repeat this search and search up
/Text/+N Move to N rows below the row where text is located
?Text? -N Move to N rows above the row where text is located
   
   
NG Move to N rows
:N Move to N rows
G Move on the last line

Content editing

A: Append content to the end of the current row

I: insert content before the cursor

I: insert content after the cursor

O: add content under the row where the mouse is located

O: add content to the row where the cursor is located

ESC: exit the editing mode.

CTRL-T: Move to the next tab

Backspace: move one character backward

CTRL-u: Delete the current

CW: Delete the character of the cursor and enter the editing mode.

Cc: Delete the row where the cursor is located and enter the editing mode.

C: Delete the characters from the cursor position to the end of the row and enter the editing mode.

DD: Delete the current row.

NDD: Delete row n

D: Delete the characters after the cursor position of the current row.

DW: Delete the character of the zip code

D}: Delete the remaining characters in the current segment

D ^: Delete the characters from the beginning of the row before the cursor.

C/Pat: Delete the content between the cursor and the first matching character

DN: Delete the content between the cursor and the next matching character

DFA: Delete the content from the cursor of the current row to the matched characters (matched characters will also be deleted)

DTA: Delete the content between the cursor of the current row and matching characters (matched characters are not deleted)

DL: Delete content from the cursor to the last line of the screen

DG: Delete the content from the cursor to the end of the file.
J: link the content of the upper and lower lines

P: insert buffer content behind the cursor

P: insert buffer content before the cursor

RX: Replace characters with x

RText: Replace the cursor with text

U: undo the last change

U: restores the content of the current row.

X: remove the characters from the cursor's position.

X: remove the character before the cursor.

NX: Delete the first n characters. The characters in the cursor will not be deleted.

.: Restore the last change

~ : Reverse the case of letters

Y: copy the current row to the new buffer.

YY: copy the current row

"XYY: copy the buffer named X of the current row.

Ye: copy it to the end of a word.

File Operations

: W Write files





: W! Write File, ignore warning information
: W!File Overwrite file and ignore warning information
: WQ Exit editing after writing the file
: Q Exit Editor
: Q! Force exit Editor
: WFile Write the file content to another file
Zz Exit the editor. If the file is changed, save the file and exit.
Exit the editor. If the file is changed, save the file and exit.
:N1, N2WFile Write content from line N1 to line N2 to file
:N1, N2W> File Append content from line N1 to line N2 to file
: EFile2 Edit file2 in command line mode of the current file
: E! Reload files from the disk
: E # Alternate file editing
   
   
: N Edit an underground row
: N! Edit an underground row (ignore warning)
   
: RFile Insert a file after the cursor
: R!Command Insert the output content after the current line.

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.