28. Common commands for VIM tools under Linux

Source: Internet
Author: User

Under Linux to do development, or even only to do management and maintenance work, but also the use of vim. As a novice, I am also just in touch, this section of my daily use or collection of vim common commands recorded.

Of course, you can learn all the commands of vim by typing it directly on the command line: Vimtutor. Vim is very powerful, a lot of cows in vim to integrate a lot of plug-ins or something, but here only the basic VIM command

Move command

H      "left J      " under K      "Upper L      " right w      "cursor moves to the first character of the next word a word forwardb      " cursor moves to the first character of the previous word e      "cursor moves to the end of the next word ge The     cursor moves to the end of the previous word $ "moves the cursor to the end of the      current line ^      " Move the cursor to the current line the first non-whitespace character 0      "moves the cursor to the first character of the current line

Note: These commands can be preceded by a count of 2$ in addition to the ' 0 ' command, and all commands above can be preceded by commands such as D$,DW.

Note: These commands can be preceded by a count of 2$ in addition to the ' 0 ' command, and all commands above can be preceded by commands such as D$,DW.

Modify command

X        "Delete one character D        " followed by any one of the displacement commands, will delete the text from the current cursor to the end of the displacement         "content, such as dw,delete word                          C        ", similar to the D command function, Different after executing the delete command in insert mode,       change dd "Delete a whole line yy       " copy a whole line p "Paste the contents of the        clipboard to the current position
Vimdiff 1.c 2.c "Create a vertical split window to compare these two files in a different place

Search command

F<a>     "single character search, FA is the current line to search for the next a,find a/string  " full-text search for a string, such as to find the word "func" is used/func         "If the text has more than one func, Pressing N will move to the next func position         "N can also accept a number count, such as 3n, immediately after the third Func? String  " is the same as the/string function, the only difference is that the search is in the opposite direction

Note:

    1. Can be used: set noingorecase ignore character case;
    2. and Command has memory function, can use multiple <UP> keys to select the search history, record the maximum number of history of the command can be changed on the session viminfo;
    3. Search for characters. */?%$^[] and other special characters to be preceded by a backslash to turn to the meaning;
    4. Search for isolated words, that is, there are no other characters (except spaces, tabs), such as only the search, do not want to search there or whether such, to use/\<the\>;
    5. Can be used: set Hlsearch to search for the word highlighting;

      Position command

      G      "Cursor moves to the last line of the file, or shift+g15g    " cursor moves to line 15th of the file, or 15GGGG     "cursor moves to the first line of the file 45%    " cursor moves to file 45% h      " The cursor moves to the beginning of the current screen m      "cursor moves to the middle of the current screen L      " cursor moves to the end of the current screen

      Note: Ctrl+g View the current cursor position

Scroll-screen command

Ctrl+u  "window roll up half screen ctrl+d  " window scroll down half screen ctrl+e  "Scroll up one line ctrl+y  " Scroll down a line ctrl+f  "window roll up a full screen ctrl+b  " The window rolls down a full screen zz "Current line is placed in the center of the      screen zt      " The current line is placed at the top of the screen ZB      "The current line is placed at the bottom

Split window

: Split    "split sideways: New      " adds a new window sideways: Vsplit   "vertical split: Vnew     " vertical Add new Window crtl+w W  "switch small window in order: Qall     " Close all windows: Wall     "Save all windows

Label (TAB) command

: tabedit filename "Creating a tab page called filename in the Vim window being edited: Tab split" new tab "GT         " move to next tab GT "         Move to next tab page

Attach a VIM command collection image (image from the network, the original source has not been tested):

So much for the time being, it will continue to be updated after learning new commands.

For additional advanced VIM commands please refer to:

The concise Vim Practice level Introduction

No plug-in vim programming tips

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.