Common commands for vim tools in Linux

Source: Internet
Author: User
Development in linux, even management and maintenance work, is indispensable for Vim. As a newbie, I am new to this topic. in this section, I will record the commonly used Vim commands I use or collect.

Development in linux, even management and maintenance work, is indispensable for Vim. As a newbie, I am also new to this topic. in this section, I will record the commonly used Vim commands I use or collect.

Of course, input vimtutor on the command line to learn all the Vim commands. Vim is very powerful. many cool people integrate many plug-ins in vim, but here we only introduce basic vim commands.

Move Command

H "left j" bottom k "top l" right w "move cursor to the first character of the next word a word forwardb" move cursor to the first character of the previous word e "move cursor to the next word ending character ge "move cursor to the end character of the previous word $" move cursor to the end of the current row ^ "Move cursor to the first non-blank character 0 of the current row" move cursor to the first character of the current row characters

Note: in addition to the '0' command, these commands can receive a count, 2 $; all the commands above can receive some operation commands, such as d $ and dw.

Modify command

X "delete a character d" followed by any displacement command to delete the text from the current cursor to the displacement endpoint ", such as dw, the delete word c "and d commands have similar functions. different commands are run in the Insert mode after the deletion is completed, change dd "delete a whole row of yy" copy a whole row of p "paste the clipboard content to the current position
Vimdiff 1.c 2.c "creates a vertical split window to compare the differences between the two files

 Search command

F "single character search, fa is to search for the next a, find a/string" in the current row to search for a string in full text, to find the word "func", use/func. if the text contains multiple func, press n to move it to the next func position.
"N can also accept the number count, such as 3n, it will find the third func
? The function of string is the same as that of/string. The only difference is that the search direction is the opposite.

Note:

You can use: set noingorecase to ignore case sensitivity;

/And? All commands have the memory function and can be used multiple times. Select search history. The maximum number of history records can be changed on session viminfo;

Search for characters .*/? % $ ^ [] And other special characters must be prefixed with a backslash;

An isolated word is found, that is, there are no other characters (except spaces and tabs). For example, if you only search for the word and do not want to search for something like there or whether, use /\ ;

You can use: set hlsearch to highlight the words to be searched;

Locating command

G "move the cursor to the last line of the file, or Shift + G15G" move the cursor to the 15th line of the file, or 15 gggg "move the cursor to the first line of the file 45%" move the cursor to file 45% H "move the cursor to the beginning of the current screen M" move the cursor to the middle of the current screen L "move the cursor to the current screen end

Note: CTRL + g to view the current cursor position

Scrolling command

CTRL + U "rolling up a half screen CTRL + D" rolling down a half screen CTRL + E "rolling up a row, it doesn't make much sense. CTRL + Y "roll down a row CTRL + F" roll forward a whole screen CTRL + B "roll back a whole screen zz" The current row is placed in the center of the screen zt "The current row place at the top of the screen zb "The current row is placed at the bottom of the screen

Split Window

: Split "vertical split: new" vertical add a new window: vsplit "vertical split: vnew" vertical add new window CRTL + W "switch small window in order: qall "close all windows: wall" save all windows

Tab command

: Tabedit filename "create a tab page named filename in the editing vim window: tab split" create a tab page gt "move to next tab page gT" move to next tab page

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.