Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common commands of vim tools in Linux system

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Linux system which vim tools commonly used commands, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

To do development under linux, even to do only management and maintenance work, there is no lack of the use of Vim. As a novice, I am also new to this section, which records the common Vim commands 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, a lot of awesome people integrate a lot of plug-ins in vim and so on, but only basic vim commands are introduced here.

Move command

H "left j" next k "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 "cursor moves to the end of the next word ge" cursor moves to the trailing character of the previous word $"move the cursor to the end of the current line ^" move the cursor to the first non-blank character of the current line 0 "moves the cursor to the first character of the current line

Note: except for the'0' command, all of these commands can accept a count of 2$ in front of them, and all of the above commands can accept some operation commands in front of them, such as dcards, dw, etc.

Modify command

X "delete a character d" followed by any displacement command, will delete the text "content" moved from the current cursor to the end point, such as dw,delete word c "similar to the d command function, different after the deletion command into Insert mode, change dd" delete a whole line yy "copy a whole line p" paste the contents of the clipboard to the current location

Vimdiff 1.c 2.c "create a vertical split window to compare the differences between the two files

Search command

F "single character search, fa is the current line search next a func a/string" full text search for a string, if you want to find the word "find", use / func "if the text has more than one func, press n to move to the next func location

"n can also be counted in front of a number, such as 3n, and you will find the third func immediately after it.

? string "has the same function as / string, except that the search is in the opposite direction.

Note:

You can use: set noingorecase to ignore character case

/ and? Commands all have memory function, you can use multiple keys to select search history, and the maximum number of recorded commands can be changed on the session viminfo.

Search characters. * /?% $^ [] and other special characters are preceded by a backslash to change meaning.

Search for isolated words, that is, those with no other characters before and after (except spaces, tabs). If you only search the and do not want to find there or whether, use /\

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

Positioning command

G "cursor moves to the last line of the file, or Shift+G15G" cursor moves to line 15 of the file, or 15gggg "cursor moves to the first line of the file 45%" cursor moves to 45% of the file H "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 to view the current cursor position

Scroll command

CTRL+U "window scrolls up half screen CTRL+D window scrolls down half screen CTRL+E" scrolls up one line, CTRL+Y "rolls down one line CTRL+F" rolls forward one full screen CTRL+B "rolls back one full screen zz" current line is placed in the center of the screen zt "current line is placed at the top of the screen" current line is placed at the bottom of the screen

Split window

: split "horizontal split: new" add a new window horizontally: vsplit "Vertical split: vnew" add New window CRTL+W w "switch small windows in order: qall" close all windows: wall "save all windows

Label (tab) command

: tabedit filename "create a tab page called filename in the vim window you are editing: tab split" create a tab page gt "move to the next tab page gT" move to the next tab page

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report