Vim tools commonly used in Linux

  

Developed under Linux, even only management and maintenance work, but also the use of Vim. As a newbie, I am also just getting in touch. This section records the Vim common commands that I use or collect on a daily basis.

Of course, you can learn all the commands of Vim by typing: vimtutor directly on the command line. Vim is very powerful, many cows integrate a lot of plugins in vim, but only the basic vim command is introduced here.

Move Commands

h "Left

j "下下

k "上

l "Right

w "The cursor moves to the first character of the next word a word forward

b "The cursor moves to the first character of the previous word

e "The cursor moves to the next The tail character of a word

ge " The cursor moves to the end character of the previous word

$ " Move the cursor to the end of the current line

^ " Cursor moves to the first non-whitespace character of the current line

0 "Mops the cursor to the first character of the current line

Note: These commands can be preceded by the '0' command. Accept a count, 2$; all the above commands can accept some operation commands, such as d$, dw, etc.

Modify Command

x "Delete a character

d " followed by any displacement command that 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, the different commands enter the Insert mode after the deletion, change

dd " Delete A whole line

yy "Copy a whole line

p "Paste the clipboard contents to the current location

vimdiff 1.c 2.c "Create A vertical split window compares the two files to different places

Search Command

f<a> " Single character search, fa is the next a search in the current line, find a

/string "Full-text search for a string, if you want to find the word "func" then use /func

" If the text has multiple func, press n to move it to Down the func position

"n can also accept the number count in front, such as 3n, it will find the next func

?string &qu Ot; has the same function as /string, the only difference is that the search direction is opposite

Note:

You can use: set noingorecase to ignore character case;

/and? The command has a memory function. You can use multiple <UP> keys to select the search history. The maximum number of history records can be changed on the session viminfo;

Search for characters. */?%$^[] and other special characters should be preceded by a backslash;

Search for isolated words, that is, there are no other characters before and after (except spaces, tabs) If you only search for the, don't want to find the there or whether, etc., use /\\<the\\>;

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

Positioning command

G " The cursor moves to the last line of the file, or Shift+G

15G " The cursor moves to the 15th line of the file, or 15gg

gg "The cursor moves to the first line of the file

45% "The cursor moves to the file 45%

H "The cursor moves to the very beginning of the current screen

M "The cursor moves to the middle of the current screen

L "The cursor moves to the end of the current screen

Note: CTRL+gView current cursor position

Scroll Command

CTRL+U "Window scrolls up half screen

CTRL+D "Window scrolls down half screen

CTRL+E "Roll up one line, no Too big Meaning

CTRL+Y " scroll down one line

CTRL+F " roll forward a full screen

CTRL+B " roll back a full screen

zz "The 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 of the screen

Split window

:split "lateral split

:new "add a new window horizontally

:vsplit "vertical split

:vnew "Add new window vertically

CRTL+W w "Switch small windows in order

:qall "Close all windows

:wall " ;Save all windows

Tab (tab) command

:tabedit filename "Create a tab page called filename in the vim window being edited

:tab split " Create a new tab page

gt " Move to the next tab page

gT " Move to the next tab page

For the time being, learn new The order will continue to be updated.

Copyright © Windows knowledge All Rights Reserved