Summary of commonly used VIM commands

Source: Internet
Author: User

Learning vim is often needed, and these commands are the most commonly used commands I've had this time, and it's very efficient to improve my
Text editing efficiency.
------------------------------------------------------------------------
A1. Text Collation class
A2. Format settings
A3. Editing techniques
A4. Clipboard tips (more convenient with Ditto)
A5. File browsing
A6. Flags and mobile
A7. Miscellaneous
------------------------------------------------------------------------

A1. Text Collation class
------------------------------------------------------------------------
: g/^\s*$/d;: Delete all empty rows
:%s/$/\r/g;: Add a blank line per paragraph
: G/^/M0;: Reverses the contents of the entire document
:%s/^/to add content/g;: Add content before each line
:%s= *$==;: Delete End of line blank
: v/^dd/d;: Delete rows with no DD at the beginning of the line
V/DD/D: Deleting a row without DD
: g/^a\{1,2}/t$;: Generate an article directory (tail) of a line that starts with a
: g/^a\{1,2}/t0;: The line with a starts at line No. 0 generate the article Directory (front)
:%s/<c-v-m>//g;: Clears the ^m (0x0D) character in the document.
<c-v-m> is to hold CTRL and not loosen, then take this
Press V,M, then loose CTRL
: g/-------/.-10,.d;: Delete previous 10 rows with-------as tag
0<c-q>10j2ld: "Delete the first two characters of the selected 10 rows, the false
Format is compact and cannot contain characters such as spaces, tabs, etc.
------------------------------------------------------------------------

A2. Format settings
------------------------------------------------------------------------
Set Nu;: Sets line number
Set nobackup;: Do not save backup
Set linespace=2;: Sets the line spacing to 2
Set tabstop=4;: Set tab indent 4 spaces
Set shiftwidth=4;: Set editor to treat 4 spaces as an indent
Set iskeyword+=33-47,58-64,91-96,123-128;: The following characters will be treated as one of the words
;: minutes (ASCII)
Set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936;: Set code
Set filetype=asm;: Using the ASM color setting
ColorScheme torte;: Choose torte color Scheme
Set tw=60 fo+=mm: 60 characters Fu, fo+mm in the Chinese environment.
------------------------------------------------------------------------

A3. Editing techniques
------------------------------------------------------------------------
: 23,25M7;: Move 第23-25 line to line 7th
/fred\|joe;: Search for Fred or Joe
/.*fred\&.*joe: Search also includes Fred and Joe's line
XP: The position of the two characters at the swap cursor around.
DDP: The position of the two lines at the top and bottom of the swap cursor.
GQG;: full-text finishing, by TW width
So 1.vim;: Execute commands stored in 1.vim (Batch command)
J;: Merging up and down two lines
10dl;: Delete 10 characters
FN: Jumps to the position of the character N on the current line
TN: Before jumping to the position of the character N on the current line
: Noh;: Cancel highlighting after finding
};: Moved to this paragraph is not
2>: Select Line all Indent 2 tab in Visual mode
------------------------------------------------------------------------

A4. Clipboard tips (more convenient with Ditto)
------------------------------------------------------------------------
: REG;: View clipboard
"5p;: Paste in 5th number clipboard
"+P;: Pasting into the system clipboard
------------------------------------------------------------------------

A5. File browsing
------------------------------------------------------------------------
: Ex;: Open the Directory Browser, note that the first letter E is uppercase
: Sex;: Open Directory list in a split window
------------------------------------------------------------------------

A6. Flags and mobile
------------------------------------------------------------------------
‘. ;: Jumps to the last modified row
`. ;: Skip to Last modified point
: Ju;: List Jump Footprints
q/: Search the Command History window
: his C;: Command line command history
------------------------------------------------------------------------

A7. Miscellaneous
------------------------------------------------------------------------
[email protected];: Executes the current line as a vim command
SP 1.txt;: Horizontal split window opens 1.txt (vs vertical Open)
? http://www.vim.org/;: Use? To bypass the escape character lookup
-----------------------------------------------------------------------

Summary of commonly used VIM 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.