Rookie's way to attack (iii)----------VIM usage Summary

Source: Internet
Author: User

Note: #表示数字, . Represents the current row, $ represents the last line, +# the down # line, and $-1 the penultimate line

Set line number last row mode set Nu/number

First, before opening the file

[Email protected] tmp]# vim + inittab

Vim + filename Opens the file and is on the last line

[[email protected] tmp]# vim +10 inittab

Vim +# filename Open the file and locate the # line

Two or three different modes

Command mode (edit function)

Input mode (content)

Last-line mode (file management function)


Mode switching

Edit mode---> Input mode

I: a bit before the cursor current position insert

A: An insert after the cursor's current position

I: Jumps to the beginning of the line where the cursor is inserted

A: Jumps to the end of the line where the cursor is inserted


O: Jumps to the next line of the cursor where the row is inserted

O: Jumps to the top row of the cursor insert


Input---> Edit:

Esc


Edit---> Last line:


Last line---> Edit:

Esc

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/8F/wKiom1V_sfjDXvJbAAGqICeEWGg053.jpg "title=" QQ picture 20150616131927.png "Width=" 620 "height=" 397 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:620PX;HEIGHT:397PX; Float:left; "alt=" wkiom1v_sfjdxvjbaagqiceewgg053.jpg "/>
















It's a little ugly, haha.

Third, move the cursor (Command mode)

Single character movement

Left h L Upper K Lower J

Multi-character movement

W Move to the beginning of the next word

e moves to the ending of the current or next word

b move to the beginning of the current or previous word

#w move to the beginning of a word

In-line movement

0 move to the beginning of the line including space characters

^ Move to the beginning of the line does not include space characters

$ move to end of line including space character

Move between rows

G moves to the beginning of the last line

GG moves to the beginning of the first line

#G move to the beginning of line #

Enter line number in the last line mode

Flip Screen

Ctrl+f down one screen

Ctrl+b on one screen

Ctrl+d Down half screen

Ctrl+u Half Screen

Iv. editing function (Command mode)

Delete d (Command mode)

x Delete the single character where the cursor is located

DW Delete the cursor position and the following word

#dw Delete the cursor position and the next # words

De deletes the cursor position and a word that follows

DD Deletes a row at the cursor location

#dd Delete the row where the cursor is located and the following total # lines

7,8 D deletes 7 to 8 rows in the last-line mode

Vim recently deleted n content will not be emptied immediately, but there is a buffer

Paste p (Command mode)

P: If you delete or copy the entire line, paste it below the line where the cursor is located, and if the copied or deleted content is a non-full row, paste it behind the character

P: If you delete or copy the entire line, paste it above the line where the cursor is located, and if the copied or deleted content is not a whole line, paste it in front of the character

Copy y (Command mode)

YW copy the cursor position and the following word

#yw where to copy the cursor and the next # words

Ye copy the cursor position and a subsequent word

YY the line where the cursor is copied

#yy a row where the cursor is copied and the following total # lines

Delete Add C (remove content first and convert directly to input mode)

CW Pruning cursor location and a word in the back

#cw the location of the cursor and the next # words

Ce redaction cursor location and a word in the back

CC to snip a line at the cursor location

#cc a row where the cursor is being censored and the following total # lines

Replace r (Command mode) (only a single character can be replaced)

R replaces multiple characters

Undo (Command Mode)

U Undo Last Action

U undo All

#u can undo previous # operations (up to 50 times)

Ctrl R undo the most recent undo operation

Find (last-line mode)

/GO along

? Look backwards.

N One More Time

N backwards at once

Visualization mode

V Select by character

V Select by Rectangular block

Find and replace S (in the last line mode)

Startaddr,endaddrs///g or GI (g: Global substitution I: ignoring character case)


This article is from the "Record Yourself" blog, be sure to keep this source http://hongtengfei.blog.51cto.com/9881650/1662299

Rookie's way to attack (iii)----------VIM usage Summary

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.