Vim Editor Usage Summary

Source: Internet
Author: User
Tags modifier


Full-screen editor: VIM

Vi:visual interface

VI, VI improved

Vim:

Pattern:

Edit mode: Command mode

Input mode:

Last-line mode:


Edit mode--Input mode:

I:insert,

A:append,

O:new Line,

I: The beginning of the line

A: End of line

O: Above New CCB


Input mode--edit mode:

Esc


Edit mode--and last-line mode:

:


Last-line mode--edit mode

Esc


Open VIM:

# VIM

# Vim/path/to/somefile

+#: #为行号, the cursor navigates to the beginning of the # line after opening the file

+/pattern: The cursor is positioned to match the first PATTERN when opened


Turn off VIM:

: Q Quit when no changes are made

: q! Do not save exit after change

: Wq Save changes and exit

: x Save changes to exit


ZZ: Save exit


Cursor Jump:

Jump between characters:

H: Left

L: Right

J: Down

K: Up


#COMMAND: A number indicating a few characters to be skipped in the specified direction before the arrow key


Jump between words:

W: The first word of the word

E: The ending of the current or subsequent word;

B: The first word of the current or previous word;


#COMMAND: Specify a multiple of the command


In-line jump:

^: jumps to the first non-whitespace character at the beginning of a line;

0: Jump to the beginning of the line;

$: Jump to end of line;


Move between rows:

#G: Jump to the beginning of line #

1G, GG jump to file header

G jump to end of file


Move between sentences:

)

(


Move between paragraphs:

}

{


Edit command:


Character editing:

X: Delete the character at the cursor location

#x: Delete successive # characters after


XP: Paste after cut (after x character is saved to clipboard)


R: replaces the character at which the cursor is located;


Delete command d:


d^ to the beginning of the line

d$ to end of line

D0 to the beginning of the line


DW, DE, delete the word after DB: delete the previous word


DD: Delete entire row


#COMMAND the # of the command to execute in the specified direction


Note: The deleted content will be saved to the buffer by the Vim editor;


Paste: P (paste, put)

If this copied or deleted content is not a full line

P: Paste at the back of the current cursor;

P: Paste at the front of the current cursor;


If the copied content is a full row (more than one line)

P: Paste below the line where the current cursor is located;

P: Above line;


Copy command: Y, yank

Y

y$, y^, y0

Ye, yw, yb


YY: Copying rows


#COMMAND the # of the command to execute in the specified direction


Changing the command: C, change

C $, c^, C0

CB, CE, CW

Cc:


#COMMAND the # of the command to execute in the specified direction


To undo a previous edit operation:

U:undo

Undo the previous edit operation;


#u


Ctrl+r:

Redo the previous undo operation


.: Repeats the previous edit operation


Turn screen operation:

Ctrl+f: one screen backward;

Ctrl+b: one screen ahead;


Ctrl+d: Back half screen

Ctrl+u: Forward half screen


Vim built-in tutorials:

Vimtutor


Vim's last-line mode


(1) Address, delimitation

: Start_pos,end_pos

#: Line #;

#,#

#,+#

.: When moving forward

$: Last line

%: Full text, equivalent to 1,$


/PAT1/: The first time the line is matched to this pattern;

#,/pat1/

/pat1/,/pat2/


After you can follow the edit command:

D, y

W, R


(2) Find

/pattern: to the tail

? PATTERN: To the header

N: Same direction as command

N: Opposite direction of command


(3) Find and replace

S: In the last line mode, the search and replace operation is done within the bounds of the address;


s/what to look for/replace with the content/modifier (/Can be replaced by other symbols to reduce the conflict of finding and replacing content, eliminating the hassle of escaping )

What to look for: Available modes

What to replace: You cannot use a pattern, but you can use a back reference symbol to refer to what the grouping brackets in the preceding pattern match to;

\1, \2, ...

&: Refers to the entire content of the "What to find" matches;

Modifier:

I: Ignore case

G: Global Substitution


/: Used for delimiters, so, to find the content or replace with the content that appears in this symbol, to use \ to escape it, use format: \/

The delimiter can be replaced with other characters: @, #等, for example;


Multi-file Mode:

Vim FILE1 FILE2 ...

: Next

: First

:p Rev

: Last


: Wqall

: Q!all


Multi-File Window segmentation:

Vim-o|-o FILE1 FILE2 ...


Ctrl+w, ARROW


Single File Window segmentation:

Ctrl+w, S:split, horizontal split

Ctrl+w, v:vertical, vertical split


Some of the working features of the custom vim:

(1) Line number

Display: Set Nu

Disabled: Set Nonu

(2) Bracket matching

Display: Set SM

Disabled: Set NOSM

(3) Auto indent:

Set AI

Set Noai

(4) Highlight Search

Set Hlsearch

Set Nohlsearch

(5) Syntax coloring

Syntax on

Syntax off

(6) Ignore character case

Set IC

Set Noic


: Help for assistance

: Help SUBJECT


The permanent effect of the feature setting is as follows:

Global configuration file:/ETC/VIMRC

User profile: ~/.VIMRC


Vim Editor 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.