Vim Command Handbook

Source: Internet
Author: User
Tags first string save file

/* This article has been by default you have passed Vimtuor training and can skillfully use most of the commands. This article is mainly for the summary and carding of the Tutor command. Suitable for learning side-by-side memory tutor that's a complete learning memory. Conforms to the cognitive law but the practice is limited. So choose to remember at this time. By the way, it seems to be a more efficient practice.


Four modes of VIM
Normal mode, also known as General mode. The Art of command-mode control cursors
Insert insertion mode, also called edit mode.
command line mode, which is called the last line mode.
Visual Visual mode this should not be controversial.

Insert Insertion Mode
I insert before cursor
A after the cursor is inserted
A Line End Insertion
I Line Header Insertion
o Insert a new row on the next line
O insert a new line in the previous line (uppercase)
s deletes the current cursor and enters insert mode
S =CC Delete all contents of the cursor line and enter insert mode (UPPERCASE)
CC Deletes all the contents of the cursor line and enters insert mode
c = $ $ Delete all content after cursor and enter insert mode
C0 Delete all the contents before the cursor and enter insert mode
c3c = 3cc Delete 3 rows and enter insert mode
C2B = d2b+i Delete the first 2 characters of the cursor and enter insert mode
c2w = d2w+i Delete 2 characters after cursor and enter insert mode

Visual visual mode Visual blocks visual Block
V Cursor Selection
V-line selection (uppercase)
Ctrl + V block selection
D Delete Selection
Y Copy Selection
: ' <, ' > w filename/absolute path

command line mode,
: w Save
: w! Force save
: Q exit
: q! forced exit
: Wq Save exit
: wq! Force save exit
: ZZ Save exit if there is a change. If not, save the exit.
: e! restore the last stored content and undo all changes.
: W file name/absolute path save file as
: R file name/absolute path reads the contents of the file and pastes it after the cursor line
: n1,n2 w filename/absolute path save content between n1,n2 as
:!command Linux can execute the shell command under Windows can execute the cmd command
Press any key to continue, recommended press ENTER
: R!command Read command output is inserted into the current text
string substitution
S/old/new Replace the first string of a row with the string old for new
s/old/new/g replace all rows with the string old to new
%s/old/new/g Replace all the strings of all rows old for new
%S/OLD/NEW/GC replace all rows of strings Old is new and pops up each string to replace the acknowledgment
I guess this g is Globe C is confirm
: Set all vim see the options that Vim is currently using

Normal mode
/string down search string n next n Previous
? String up-search strings
Open Ignore case when searching string
? string\c
/string\c
-----------------------------------------------------------------------
Operator-operators, which represent things to do, such as D for deletion
Numbe R can be appended to the number representing the number of repetitions of the action
Motion-action, which represents movement on the text being manipulated, such as w for word (word), $ for line end, and so on.
------------------------------------------------------------------------
Number Motion
Digital action

Operator number Motion
Command Number action

------------------------------------------------------------------------
$ cursor jumps to the end of the line
0 cursor jumps to the beginning of the line
H cursor moves to the top row of the screen
M cursor moves to a line in the middle of the screen
L cursor moves to the bottom line of the screen
DD Delete a row
X Delete one character after cursor
X Delete one character before cursor
U perform one undo command
U restore the initial state of the bank
Ctrl+r undo ' Undo Command '
J Merge row deletes the white space between two rows
YY Copy a row
P paste under the cursor line
P paste a line on the cursor
R replaces a single error character
R replaces multiple characters consecutively
~ Toggle the current character case
W moves to the beginning of the word
E moves to the end of the word
CTRL+G display the cursor's row and status information
GG jumps to the first line
G jumps to the last line
80gg jump to line 80th or G
Enter to move the cursor to the first line of the next line
Z Enter Scrolls the screen and moves the current line to the first line of the screen
. (point) Repeat last action
----------------------------------------------------------------
Number Motion
Digital action
------------------------------------------------------------------------
2x 2 characters after deletion of the cursor
1j cursor moves down 1 lines
1k cursor moves up 1 lines
1h cursor moves left 1 lines
1l cursor moves right 1 lines
3p Paste 3 times p content
CW deletes the current cursor to the end of the word and automatically enters insert mode (modifies a word)
Ce=cw
d$ Delete the contents of the cursor but does not enter insert mode
D0 Delete the content before the cursor but does not enter insert mode
y$ Copy Cursor Content
Y0 Copy the contents before the cursor
DW Delete A word that includes a space after a word
De removes a word that does not include a trailing space
2DD Delete 4 rows
2yy Copy 2 rows
2w move right to the beginning of 2 words
2e move right to the end of 2 words
------------------------------------------------------------------------
Operator number Motion
Command Number action
------------------------------------------------------------------------
C2E Delete 2 words after entering insert mode
C10J Delete 10 rows and enter insert mode
d2w Delete Two words
y2w copy Two words
y3y = 3yy Copy 3 rows
d4d = 4DD Delete 4 rows
D1gg = d1g Deletes everything from the line of the cursor up to 1 rows (including the cursor row and line 1th) Y1gg = y1g copy everything from the line of the cursor up to 1 rows (including the cursor rows and 1th lines)
DG deletes everything down from the line where the cursor is located (including the line where the cursor is located)
YG copies everything down from the line where the cursor is located (including the line where the cursor is located)

---------------------------------------------------------------
CTRL key combination
----------------------------------------------------------------
CtrL O returns the position where the cursor was just repeated by pressing
CTRL I returns CTRL O Previous position
CtrL F Move down one page
CtrL D moves down half a page
CtrL B Move up one page
CtrL U Move Up half page

There are other commands that can be combined naturally. For example, an EA is inserted after a word. More command combinations need to be understood and practiced to form neural reflexes.

Vim Environment parameter settings: Edit the VIMRC file, depending on the operating system you are using
: Edit ~/.VIMRC This is the command used by the Linux system
: Edit $VIM/_VIMRC This is the command used by the Windows system

Set line number
Turn on set nu
Close Set Nonu

Find string ignores case
Opening the Set IC
Close Set Noic

String highlighting
Hlsearch Open
Nohlsearch off

Display the search content while searching
Set Incsearch Open
Set Noincsearch off

' IC ' ignorecase ' ignores letter case when searching
' Is ' ' incsearch ' shows partial match when finding a phrase
' HLs ' hlsearch ' highlights all the matching phrases
The option name can be either a full version or an abbreviated version.

Set Auto Indent
: Set Autoindent Open
: Set Noautoindent off

Set whether to display mode hints such as insert
: Set Showmode Open
: Set no Showmode off

Set syntax highlighting
: Syntax on open
: Syntax off

Vim Command Handbook

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.