Common commands for Vim

Source: Internet
Author: User

Use of the VIM editor
General mode
To move the cursor:
Ctrl+f screen moves down one page, equivalent to page Dowb button
Ctrl+b screen moves up one page, equivalent to page Up button
0 or function key home moves to the front character of this line
$ or Function key end to move to the last face character of this line
G move to the last line of this file
NG N is a number. Move to the nth row of this file
GG moves to the last line of this file
N<enter> N is a number, the cursor moves down n rows

Search and Replace:
/word look down, Word is the string to find
Word looks up, Word is the string to find
n n This is the English key, which means "repeat the previous search job."
n n This is the English key, which represents the reverse of the previous search job.
: N1,n2s/word1/word2/g looks for word1 between N1 and N2, and replaces the string with Word2!
: 1, $s/word1/word2/g look for the word1 string from the first line to the last line, and replace the string with Word2! Common
: 1, $s/word1/word2/gc and display prompt character before substitution to confirm to user (confirm) need to replace

Delete, copy, and paste:
X,x in a line of words, X is the backward deletion of a character (equivalent to the [Del] key), X is to delete a character forward (equivalent to [backspace] is the backspace)
DD Delete the entire column where the cursor is located (common)
NDD N is a number. Delete the down n column where the cursor is located, for example, 20DD to delete 20 columns (common)
YY the line where the cursor is copied (common)
p,p paste, lowercase p is pasted for the next line, upper case p is pasted up
U Restore a previous job
Ctrl+r redo the last job search
.  Decimal point. Repeat a previous job

Edit mode
Insert mode:
I,i i is "inserting from the current cursor," and I is "inserting at the first non-whitespace space at the current line."
A,a A is "inserting from the next character where the cursor is currently located" and A is "starting at the last character of the line where the cursor is located." (
O,o This is the case of the English letter O. o Insert a new line at the next line where the cursor is currently located; o Insert a new line on the previous line where the cursor is currently located!
Replace mode:
R,r R will only replace the one character where the cursor is located, and R will always replace the text of the cursor until ESC is pressed

Instruction mode
: W writes edited data to the drive file
: w! If the file property is read-only, the archive is forced to be written. However, in the end can be written, or with you on the file permissions related Ah!
: Q Leave VI
: q! If you have modified the file, do not want to store, use! Do not modify the file for forced departure
: Wq Save exit, wq! Force save exit
: w [filename] saves edited data to another file
: R [FileName] in the edited data, read into the data of another file. The file "filename" will be added to the cursor row after the
: n1,n2 w [filename] stores the contents of N1 to N2 as the filename of this file
:!command temporarily leave VI to command mode to perform command display results! For example [:! ls/home] in VI to see the file information under/home with LS output!

This article is from the "Small Network Management Growth Road" blog, please be sure to keep this source http://sqlweeks.blog.51cto.com/7344588/1683634

Common commands for Vim

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.