Vim Common Operations Commands

Source: Internet
Author: User
Tags save file

Open multiple Files
Vim File1 file2
: Open/:e does not close vim open file

Sub-frame window
: New Window
: SP Landscape
: VSP Portrait
ctrl+w window switch
: TABC Close the current window
: Tabo Close All windows
: Ctrl+w + Vertical expansion (Increased number of rows)
: ctrl+w-Zoom Out (decrease in number of lines)

inter-file switching
ctrl+6-Next file
: bn-Next file
: bp-Previous file

Copying between multiple files
CTRL + V into visual mode
"+y/" *y copy
"+p/" *p paste

Copy
YY Copy Line
NYY Copy N rows
YW copy Word
: 10,100 Copy 200 Copy the contents of line 10th to 100th and paste to line 200
Open a file and copy a few lines to another file under the file (for example, to Test.txt), overwriting the contents of the Test.txt
10,100w!test.txt, Note: Copy the contents of line 10th to 100 into the test.txt and overwrite the contents of the Test.txt
Copies a few lines to another file under the file, but does not overwrite the original content, i.e. append
10,100w!>>test.txt, Note: Copy the contents of rows 10 through 100 to the end of Test.txt.

Paste
p/p paste

Cut/Delete
DD Delete Row
DW Delete Word
d$ current to end of line
d^ current to the beginning of the line
3DD, that is, from the current line + the next two lines are cut
1,10 m 20 cut 1-10 rows to 20 rows

Find
/key find key backwards from the current cursor position
? Key looks forward from the current cursor position to key
/\<key\>,?\<key\> Exact Match find key
N,n after finding the key, n jumps to the next position, N jumps to the previous position

Replace
s/string to be replaced/new string/replace only once
S/the string to be substituted/new string/g replace when forward
%s/the string to be replaced/new string/g bulk replace
n,/the string to be substituted/new string/g replace N to the last line
n,ms/string to be replaced/new string/g from N line to M line
Note:/Can be expressed in # so that the/in the string does not need to be escaped

File browsing
: Ex Opens the Directory browser, can browse all the files in the current directory, and can choose
: Sex horizontally splits the current window and opens the Directory browser in a window
: Files/:ls Displays the current buffer condition
: QA or qa! Leave vim in the case of multiple documents open. A is the meaning of all.

Vim and Shell switching
: Sh/:shell can switch to shell command line without shutting down VI
Ctrl+d/:exit from Shell to VI

Multi-label
Tabnew FileName adds a label
: TABC Close the current tab
: Tabo Close all other tabs
: Tabs View all open tabs
: TABP before a
: Tabn after a

Cursor positioning shortcut keys
To the specified line: line number, line number g
To file header 1G
To end of file G
Lower left upper right h,j,k,l
Next word W, previous word b
To the beginning ^
To end of line $
End of line Insert A, add empty line O

Save, exit
Save File: W
Close file: Q
Save and Close file: Wq
Do not save forcibly closed files: q!
Close all Files exit: QA

Move screen
Next Page Ctrl-f
Page UP Ctrl-b
Ctrl-e the next turn.
Ctrl-y up the line

Vim Common Operations Commands

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.