Vim Practical Manual-Edit (insert, delete, copy, and replace)

Source: Internet
Author: User

1. Insert text

I, of course, is commonly used. But if I is used only, it is too TB. Remember I, O, and,
Of course, it is case sensitive. It generally distinguishes the concepts before and after. This is the principle that Vim is designing various commands.

Operation memory for Command Execution
-----------------------------------------------------------------
I insert characters on the left of the cursor
I insert characters at the beginning of a row
A. add text to the right of the cursor
A. Add text at the end of a row
O insert an empty row under the current row
O insert an empty row to the current row
20I-[ESC] inserts 20 hyphens (this is a very useful command, such as inserting separators, inserting +, etc)
-----------------------------------------------------------------

The following are some common settings:

Operation memory for Command Execution
-----------------------------------------------------------------
: Set showmode: When VI is in input mode, a prompt is displayed.
: Set SM instant display of paired) or}
: Set Ts = N: Set the tab to n (default value: 8)
: Set AI next line from the front line indent position (this is in the writeCode)
-----------------------------------------------------------------

Ii. delete text

Operation memory for Command Execution
-----------------------------------------------------------------
X Delete the character of the cursor
6x Delete the characters at the cursor position and 5 characters on the right
X Delete the previous character
Dd deletes the current row
Delete 4 lines in 4dd
64dd Delete 64 rows
DW deletes a word
D0 Delete to the beginning of a row
D $ Delete to the end of the row
D. delete a region (only for VIM)
P paste the cut text to the following (entire line) or right (partial line)
P paste the cut text above (entire line) or left (partial line)
"Add paste the current row into buffer
"AP paste the content in buffer A to the current position
J. merge the current row into the next row
Change the location of two characters in XP
-----------------------------------------------------------------

3. Replace text
operation memory for command execution
-----------------------------------------------
RCH replaces the character at the cursor position with CH
r replaces the text on the right of the cursor
S Replace the character of the cursor with any character
S to replace the entire line of content
CW Modification one word
C. Modify the text (Vim) in the region)
~ Change the uppercase and lowercase letters in the scanned or area
! Tr' [A-Z] ''[A-Z] 'converts letters in the region to uppercase (Vim)
! Tr '[A-Z] ''[A-Z]' converts letters in the region to lowercase (Vim)

-----------------------------------------------------------------

4. Copy text
Operation memory for Command Execution
-----------------------------------------------------------------
YY copy the current row
6yy copy six rows
Copy a word in YW
Y replication region (Vim)
P paste the copied text to the right or below
P paste the copied text to the left or above
"Ayy copies the current row to buffer
"AP restores content in buffer.
-----------------------------------------------------------------
A register concept is used here. The General Delete and copy functions use the default register,
For example, if two rows are copied and pasted immediately, the two rows are pasted.
If a delete operation is performed in the middle, the deleted content is pasted.
If you do not want to cause such confusion, you need to specify a register.
The register prefix is a quotation mark :".
As mentioned above, if a row is copied to register a, it is: "Ayy
Paste A to the AP.
This function is very useful.

Take a closer look at the rules of several Vim commands,
1. Operation Syntax: Numbers + operations + special characters. For example, multi-row operations: number of rows + actions, fart: 6dd, delete 6 rows, 6yy, copy six rows, and so on.
For example, delete 6 words: 6dw..
3. Case sensitivity. As mentioned above, this is also summarized here. This is not sense. It is just about front and back.

 

Link: http://www.pakey.net/index.php/post/vim-learn-edit.html

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.