Common commands for the VI editor in Linux

Source: Internet
Author: User

Cursor control

H Cursor moves left
J Cursor moves down
K Cursor moves up
L (or SPACEBAR) Cursors Move Right
W Move forward one word
B Move one word backwards
E Moves one word forward, and the cursor points to the end of the word
( Move to the header of the current sentence
) Move to the header of the next sentence
{ Move to the header of the current segment
} Move to the header of the next paragraph
[[ Move to the header of the current section
]] Move to the header of the next section
0 Move to the header of the current line
$ Move to the tail of the current line
^ Move to the first non-whitespace 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 current line where the character n is
H Move to the header of the current screen
M Move to the middle of the current screen
L Move to the tail of the current screen
N H Move to n rows at the top of the current screen
N L Moves to n rows at the end of the current screen
Ctrl-f Move to the next screen
Ctrl-b Move to the previous screen
Ctrl-d Move Down half screen
Ctrl-u Move Up half screen
Z RETURN Refresh the screen, adjust the screen so that the current cursor in the refreshed screen after the header (is not understood??? If you don't understand it, try to know what it means.
Z. Refreshes the screen, adjusts the screen so that the current cursor is in the middle of the refreshed screen
Z- Refreshes the screen, adjusts 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 contents of the last search to search down once
? text Search up text
? Repeat on this search up one time
N Repeat on this search, search down
N Repeat the search on this, search up
/text/+n Move to the next n line of text
? text?-N Move to the top n row of the text row
N G Move to N rows
:N Move to N rows
G Move in the last row

File operations

: W Write file
: w! Write file, ignore warning message
: Wq write file and exit edit
: Q Exit Editor
: q! Force Exit Editor
ZZ exits the editor and if the file is changed, save and then exit
: X Exit Editor, save and exit if file is changed
: e! Re-loading files from disk
: n Edit the ground line
: n! Edit an underground row (ignore warning)

Content editing

A Append content at the end of the current line
I Insert content before cursor
I Insert content after cursor
O Add content below the line where the mouse is located
O Add content above the row of the mouse
ESC key Exit edit mode
Space key Move to the next tab
cw Delete the character of the cursor and enter edit mode
Cc Delete the row where the cursor is located and enter edit mode
C Remove the character from the cursor's location to the end of the line and enter edit mode
Dd Delete When moving forward
D Deletes the character following the position of the current row cursor
Dw Delete the character that the cursor contains
D Delete the character after the current segment cursor
d^ Delete the character before the cursor to the beginning
J Link the contents of the next two lines
P (lowercase) Insert the contents of the pasteboard after the cursor
P (uppercase) Insert the contents of the pasteboard in front of the cursor
Rx Replace the character of the cursor position with X
U Undo the last change
U Restores the contents of the current row
X Delete the character of the cursor position backwards
X Remove the characters in front of the cursor forward
Nx Delete the preceding n characters, the cursor character will not be deleted
~ Reverse the case of letters
. (Point number) Revert to the last change (equivalent to CTRL + Z)
Y Copy the current line to the new pasteboard
Yy Copy when moving forward

Common commands for the VI editor in Linux

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.