Various common commands and usage of VIM editor in Linux

Source: Internet
Author: User
Tags exit in

common commands and usage of the Vim editor in Linux ( note strictly case-sensitive and in Chinese and English ):

The VIM editor has three modes : edit mode, input mode, and last line mode.

Mode conversion:

Edit Mode "Input mode:

I: Before the character of the cursor, into the input mode (that is, after the end of the cursor before the character input); I: At the beginning of the line of the cursor, into the input mode (that is, after the end of the beginning of the input, not including the beginning of the blank)

A: After the cursor character, into the input mode (that is, after the end of the character after the cursor entered);

A: At the end of the line where the cursor is in the input mode (that is, after the end of the line input, the end of the row includes spaces)

O: Create a new line below the character of the cursor and switch to input mode;

O: Create a new row on the line where the cursor is located, and switch to input mode.

Input mode "" Edit mode:

Esc

Edit mode: The last line of the mode

: Enter the last line mode

Last-line Mode "edit mode:

ESC + Esc key (i.e. two consecutive ESC keys)

Note: There is no direct conversion between the input mode and the last line mode.

Open File command:vim file specific path and name (default open edit mode)

Vim +# When opening the file, the cursor is fixed on line #;

VIM + cursor is fixed on the last line when opening a file

Vim +/pattern When you open a file, the cursor is fixed on the line that is first matched to the PATTERN (the text and the regular expression)

Close File command:

exit in edit mode: ZZ (press the Z key two times consecutively)

Exit in the last line mode:

: Q exit (without modification)

: Wq or X saved and launched

: q! Forced exit (modified but not saved)

: W Save

: w! Force Save

cursor Movement:

Character-by-word movement:

H left J down k up L right

Up or down arrows

#h/j/k/l Move the # bit/line character (#为数字)

Move by Word:

W: Move to the beginning of the next word

E: Move to the ending of this word (the cursor is not at the ending) or the next word ending (cursor at the ending)

B: Move to the beginning of the word (the cursor is not at the beginning of the word) or the beginning of the previous word (cursor at the beginning of the word)

#w/e/b: Moving # words (#为数字)

In-line movement:

0: Move to the absolute beginning (including spaces)

^: Move to the beginning of the line (excluding spaces)

$: Move to end of line

Move between rows:

#G: Move To Line # (absolute number of lines)

G: Move to the last line

: # Move to # # line (last line mode)

Flip Screen:

Ctrl+f (forward): Flip one screen down

Ctrl+d (down): Flip down half screen

Ctrl+b (backward): Turn up one screen

Ctrl+u (UP): Flip up half screen

Delete character:

X: Delete the character at the cursor location

#x: Remove the total # of characters (#为数字) that include the cursor location

Delete command:d (delete)

DD: Deletes the entire line of the cursor #dd: Delete The total # lines that include the cursor within and below the line

Shared with the word Jump command:

#dw, #de, #db

copy and paste:

Copy: Y (Yank) usage is similar to delete command D

YY: Copy the entire line of the cursor #yy: Copy includes the line within the cursor and the following total # lines

#yw, #ye, #yb

Paste: p/p

P (paste): If the entire line of content is copied, create a new line under the position where you want to paste the cursor and paste it, or paste it after the cursor position if it is not the entire line.

P (paste): If the entire line of content is copied, create a new line above the position where you want to paste the cursor and paste it, or paste it before the cursor position if it is not the entire row.

Modify : Delete the specified content and enter the input mode

C (change) usage is similar to deleting D

Replacement mode:

R (replace) enters replacement mode

Revocation:

u: Undo Last Action

#u: Undo Previous # Operations

Ctrl+r: Undo the last undone operation

repeat the last action:

. : Represents the same action as the last action (input, delete, paste, etc., not including undo actions)

visualization operation (visualization):

V: Select by character

V: Select by row

keyword search:

/pattern: Using regular expressions to find (without adding ')

? Pattern: Ibid.

n/n: Turn down/up to see multiple keywords

Find and Replace:(in the last line mode)

%/1,$: Indicates global search

Search for replacement commands using s///or [email protected]@@ 等

Example: Replace the global blank line with ' Space lines '::% s/^$/space line/g

Change the global ' std ' string to spaces:: 1,$ s/std//g

This article from "Xpzz51" blog, reproduced please contact the author!

Various common commands and usage of VIM editor in Linux

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.