Linux CentOS Vi/Vim command

Source: Internet
Author: User

Linux CentOS VI/VIM command

INSERT command:
 
A attaches text behind the cursor
A adds text at the end of the line
I insert text before the cursor
I. Start inserting text in this row
O Insert a new line under the cursor
O Insert a new line to the cursor
 
Positioning command in VI:
 
H. left-click to move one character to the left
J. Move down a line
K. Move a row up
L. Right-click the direction and move one character to the right.
 
$ Move to the end of the row
0. Move to the beginning of the line
H. Move to the top of the screen
M. Move to the center of the screen
L move to the bottom of the screen
 
 
 
[CTRL] [d] half a page [PageDown]
[CTRL] [f] to the next page
[CTRL] [u] up half page
[CTRL] [B] [PageUp]
 
 
 
: Set nu
: Set nonu cancel row number
Gg to the first line
G to the last line
NG to n
: N to row n
 
DELETE command:
 
X. Delete the character at which the cursor is located
Nx: Delete the last n characters at the cursor location
Dd: Delete the row where the cursor is located, and ndd deletes n rows.
DG. Delete the content from the row where the cursor is located to the end.
D. Delete the cursor from the position to the end of the row.
: Nl, n2d, delete rows in the specified range
Copy and cut commands:
 
Yy and Y copy the current row
Nyy and nY copy n rows below the current row
Dd: Cut the current row
Ndd cut n rows below the current row
P and P are pasted under or on the row where the current cursor is located.
Replacement and cancellation commands:
 
R, replace the character where the cursor is located
R. Replace the character from where the cursor is located and Press Esc.
U. Cancel the previous operation.
Search and replace commands
 
/String: Specifies the string to be searched forward. Case sensitivity is ignored during search: set ic
N. Search for the next occurrence location of a specified string
: % S/old/new/g, full text replacement of the specified string
: Nl, n2s/old/new/g, replace the specified string within a certain range
 
Save and exit: wq. You can also use ZZ to replace this command.

  • 1
  • 2
  • 3
  • Next Page

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.