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

Common commands in vim mode

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

Share

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

This article mainly introduces "common commands in vim mode". In daily operation, I believe many people have doubts about common commands in vim mode. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "common commands in vim mode". Next, please follow the editor to study!

Command mode (command mode) description: no matter what mode you are in, just press the ESC key You can enter command mode to view commands: Ctrl+u screen up half page Ctrl+d screen down half page Ctrl+b screen up page Ctrl+f screen down one page h cursor moves one character j to the left Move the cursor down one character k cursor up one character l cursor move one character to the right query command: / word after pressing enter Look for the word string after the cursor? after word presses the enter key, look for the word string before the cursor:% s/word//gn query string "word" the number of times it appears in the file:% s/word1/word2/g find word1 for the whole file and replace it with word2 If word2 is omitted, that is:% s/word1//g means to replace the string "word1" in the file with "": s/word1/word2/g looks for word1 on the current line of the cursor, and replace it with word2: N1 Magi n2sUnix word1xword2word1 between lines N1 and N2. And replace with word2 positioning command:: set nu display line number: set nonu cancel line number gg navigate to the first line of the text G to the last line of the text: n to the nth line of the text 0 (numeric 0) cursor moves to the first character of the current line (can be null) $cursor moves to the last character of the current line (can be null) exit command:: Q exit Applies to unmodified files: Q! Forced exit, applicable to modify the file without saving exit: W save the edited data to the hard disk file: wq or: X save and exit shift+zz save and exit The same function as: wq: W [filename] saves the edited data to another file on the hard disk: N1 filename N2 w [filename] saves the contents of N1 to N2 lines to a file named filename: r [filename] reads the data in another file when editing the data. Add the contents of the filename file to the next line of the cursor copy command: yy copy cursor line Y1G copy cursor line to the first line yG copy all data on the cursor line to the last line Ynj (n stands for number) copy cursor line down nq1 line p P p pastes the copied data on the next line of the cursor P to paste the copied data on the previous line of the cursor to delete the command: XMagi X x to delete one character backward X is the n characters after the previous deletion of a character nx delete cursor dd delete cursor ndd delete cursor n line: N1 N2d delete the specified range of rows D delete the content from the cursor to the end of the line 1G delete all data from the line to the first row of the cursor dG delete all data insertion mode from the row of the cursor to the last row (--INSERT -) description: press ESC Enter command mode insert command: I insert a before the cursor insert an after the cursor insert An at the beginning of the current line of the cursor insert An at the end of the current line of the cursor O insert a new line on the next line of the current line of the cursor O insert a new line on the previous line of the current line of the cursor Change command: r replace the character R where the cursor is located. Replace the character R from the cursor. Press Esc to cancel the command: U cancel the previous operation (undo) ctrl+r returns to the last line mode before (redo) description: in the command mode, enter the English colon to enter the last line mode, after the execution of the command starting with the colon, automatically return to the command mode. Print command:: other commands under echo $JAVA_HOMEvim: ctrl+s means to stop output to the terminal: vim is as if it has been stopped, pressing any key does not work. Ctrl+q restore output to the terminal: set fileencoding view the encoding format of the file: set fileencoding=utf-8 sets the encoding format of the file

=

More Command 1) introduction: is a text filter based on the vi editor, which displays the contents of the text file by page in a full-screen manner.

2) built-in shortcut key in more: press enter key: display the next line of text press the Spacebar: display the next screen content of the text / pattern: find pattern press b key: display the previous screen content press f key: display the next screen content press d key: scroll back half screen press Q key: exit more command Press h key: display help information so far The study of "common commands in vim mode" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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