Vim Editor-the use of detailed

Source: Internet
Author: User

Vim Editor

1. Basic mode:

Edit mode, Command mode

Input mode;

Last-line mode;

2. Open file, convert between modes

#vim [OPTION] ... FILE ...

+#: After opening the file, just leave the cursor at the beginning of line #

-/pattern: After opening the file, the cursor is directly at the beginning of the first line that is matched to the PATTERN;

Mode conversion:

Edit mode--Input mode

I:insert, enter at the current cursor location

A:append, the input after the current cursor is located

O:open, a new line is entered below the current cursor

I: Input at the beginning of the line where the current cursor is located

A: Enter at the end of the line at the current cursor

O: Enter new line above the current cursor line

Input mode--edit mode

Esc

Edit Mode--last-line mode


Last-line mode--edit mode

ESC (Normally press 2 times, press 1 times to react very slowly)

Shutdown mode:

: Q No modification at the time, in the last line mode exit

: q! Do not save the changes made, forcing not to save does not exit

: Wq Save the changes made, save exit

: X Save exit

: W/path/someswhere saved to the specified place

ZZ in edit mode, save exit directly without switching to the last line mode and then save exit

3. Cursor Jump

Jump between characters

H: Left

J: Down

K: Up

L: Right

Word single Jump

W: Jump to the beginning of the next word

E: Jump to the ending of the current or next word

B: Jump to the beginning of the current or previous word

Beginning line End Jump

^: Jump to the beginning of the current line

0: Jump to the line of the current line

$: Jumps to the end of the current line

Move between rows

G: Jump to the last line

#G: Jump To Line #

1g,gg: Jump to First line

Editing commands for 4.vim

Character editing

X: Delete the letter where the current cursor is located

#x: Delete the number of # characters to the back of the current cursor

XP: Swaps the exchange of characters behind the current cursor

R:replace, press the R key and press the a key to replace the character where the current cursor is located with a

Delete command:

D: Delete command, can be combined with the cursor jump character, to achieve in-range delete

d$: Deletes the contents of the current cursor at the end of the line

D^,D0: Deletes the contents of the current cursor at the beginning of the line

DD: Delete the entire row of the line where the label is located

#dd: Implementation in multi-line deletion, starting with the current cursor behavior

Dw:

De

Db:

Paste command (p,put,paste):

P: If the buffer is in advance, it will be pasted below the line where the cursor is currently located, otherwise, paste it at the back of the cursor

P: If the buffer is in advance, it is pasted at the top of the line where the current cursor is located, otherwise, paste at the back of the cursor

Copy command (Y,yank):

Y: Copy, working behavior similar to D command

y^: Copy the current cursor at the beginning of the line

Y0: Copy the current cursor at the beginning of the line

y$: Copy the current cursor at the end of the line

YY: Copy an entire row of the line that the current cursor is in

#yy: Implements multi-line replication, starting with the current cursor

yw

Ye

Yb:

Change command (C,change):

C: Modify

Edit mode--Input mode

C $: Modifies the cursor to the end of the line, directly deletes the contents of the cursor at the end of the line and changes to insert mode

c^: Changes the cursor to the beginning of the line, directly the cursor at the beginning of the content deleted, and into the insertion mode

C0: Changes the cursor to the beginning of the line, directly the cursor at the beginning of the content deleted, and into the insertion mode

cw

Cb:

Ce:

CC: Modifies the entire row and becomes insert mode

To undo previous edits (U,undo):

U: Undo the previous action

#u: Undo the previous specified number of actions

Undo previous undo: After you undo the action with U, you regret it and want to change back

Ctrl+r

Repeat the previous edit action:

.

Visualization mode:

V: Selected by character

V: Selected by row

Note: Often combined with editing commands, to implement multi-line deletion, replication, etc.

Turn screen operation:

CTRL+F: Flip a screen to the end of the file

CTRL+B: Flip a screen to the file header

Ctrl+d: Turn half screen at the end of the file

Ctrl+u: Turn half screen to file header

Last-line mode in 5.vim

Built-in command-line interface

(a) Address definition

: Start_pos,end_pos

#: The specific # line, for example, 2 means line 2nd

#,#: Starting from the first line to the first line

#,+#: Add a few lines from the first line

.: Point indicates when forward

$: Indicates the last line

$-1: Indicates the 2nd line of the countdown

%: Full text, equals 1,$

/pat1/,/pat2/

Starting from the first pattern PAT1 match, to the first time by the pattern

Vim Editor-the use of detailed

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.