Vim Editor--common operations and finishing

Source: Internet
Author: User

Note: The following actions are performed in the command state and do not enter the insert state.

1. Delete

DD Delete a row

NDD deletes n rows starting at the current line
DW deletes a character starting with the current character
NDW Delete n characters starting with the current character
d$, D deletes a line of characters starting with the current character
d) Delete to the beginning of the next sentence
D} Delete to the beginning of the next paragraph
D Enter Delete 2 rows

2. Copy and paste

VI Set auto indent: Set smartindent
VI Settings Display line number: Set number or set Nu set Nonu to cancel line numbers

Co:copy M:move

: 9,15 copy 16 or: 9,15 Co 16
: 9,15 move 16 or: 9,15 m 16

Save As:

Move the cursor to the start line, enter the MA
Move the cursor to the end line, enter MB
Then: ' A, ' b w ' filename filename exists in the current directory

3. Cursor Movement

Move left to right: 20h or LEFT ARROW key (<--), default 1 20l or RIGHT arrow

Move up: 20J or up ARROW key 20+ 20k or up ARROW key 20+

N<space> that n means "number", pressing the number and then pressing the SPACEBAR, the cursor moves the n characters of the line to the right. For example 20<space>, the cursor moves 20 character distances to the back.

N<enter>n is a number. Move the cursor down n rows (common)

$ or Function key [end] moves to the last face of this line prompt (commonly used), where the $ in the regular means the end meaning

GG moved to the first line of this file, equivalent to 1G Ah! Common

4. Other common

DD Delete positive line yy copy positive row pp paste positive row

x, x in a line of words, X is the backward deletion of a character (equivalent to the [Del] key), X is to delete a character forward (equivalent to [backspace] is the backspace bar) (commonly used)

P, p p copies the copied data, pastes it on the next line of the cursor, and p pastes the copied data to the previous line of the cursor

D1G Delete all data from the row to the first row of the cursor

Y1G Copy all data from the row to the first row of the cursor

DG deletes all data from the row to the last row of the cursor

d$ Delete the last character of the line where the cursor is located

D0 Delete all data at the beginning of the line with the same character as the cursor

U undo. Common

Ctrl + R undo revocation. Common

5. Region Selection Replacement Search

/string look under the cursor for a name called string string

? string looks for a string that is named string above the cursor

N Forward lookup, search for a string that can be understood as next

N Reverse lookup, search for a string that can be understood as not next

n is from top to bottom, n is from bottom to top

V and V are primarily for row selection, and CTRL + V. is a choice of columns, and, in terms of flexibility, CTRL + V is more flexible

: n1,n2s/string1/string2/g Here N1 is the number of start rows to find, N2 is the number of rows to find the end. ": 2,7s/ddd/fff/g" in line 2nd, line 7th, replace DDD with FFF

: 1, $s/string1/string2/g look for the string1 string from the first line to the last line, and replace the string with string2! Common

: 1, $s/string1/string2/gc look for the string1 string from the first line to the last line, and replace the string with string2! and display the prompt character before the substitution to the user to confirm (confirm) whether need to replace! Common

Refer here



Vim Editor--common operations and finishing

Related Article

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.