I have used the vi editor for several years, but I have never used some practical uses. After listening to the introduction of Linux in the python video today, I still learned a few new tricks. 1. :set nu displays line numbers 2. gg--------to the beginning of the file 3.G--------To the end of the file 4.u---------Undo operation 5.Ctrl+r-----Redo 6.:/better, press Enter to search for words matching better, press n to search for the next one 7.:s/better/dog, press Enter to replace the first "better" in this line with "dog" :s/better/dog, press Enter to replace all better in this line with dog :%s/better/dog Enter, replace all better in this file with dog 8. vi -O2 file1 file2 Use one screen to display both file1 and file2 for easy editing. Press ctrl+w to switch from one file window to another. Expanded content Common Linux commands - Learned cd (change the path) rm (followed by -rf to delete a file or folder) ls (view the files and folders in the current path) mkdir (create a folder) touch (create a file) Vim commonly used commands Cursor positioning; hjkl move up, down, left, and right 0 $ Jump to the beginning or end of the line gg shift+G jumps to the beginning or end of the entire file 1G, 2G, 3G........NG, jump to the beginning of line 1.2.3 N /String(n N can be looped) quickly locate a certain line, /^d quickly locates the line starting with d, /txt$ quickly locates the line ending with txt. Text editing (small amount) y copy. yy 3yy ygg yG (in lines) d delete dd 3dd dgg dG (in lines) p Paste x Delete the character where the cursor is D Delete from cursor to end of line u undo ^r redo Undo, redoCtrl + r r Modify a character Enter other modes a Enter insert mode, insert after the cursor i Enter insert mode, insert before the cursor o Insert into a new line A shift + A insert at the end of the current line : Enter last line mode (extended command mode) v Enter visual mode ^v Enter visual block mode Ctrl + v V Enter Visual Line Mode R Enter replace mode and perform batch replacement after the cursor, similar to Insert for text on Windows VIm keyword autocompletion in insert mode Ctrl + p / n The above are all the knowledge points and extended content introduced this time. Thank you for your learning and support for 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief talk about Mysql index and redis jump table
In the world of web development, frameworks are ve...
This article records the installation and configu...
Sometimes the input box is small, and you want to...
Use vite to build a vue3 project You can quickly ...
Detailed explanation of the implementation method...
<br />Sometimes you may be asked questions l...
Table of contents Creating Arrays in JavaScript U...
How can we say that we should avoid 404? The reas...
Current demand: There are two tables, group and f...
Preface This article mainly shares with you an ex...
Summary This article will introduce the following...
Recently, a new requirement "front-end cache...
Detailed explanation of MySQL stored procedures, ...
1. Import the basic style of external CSS files U...
Table of contents Why use Docker? Docker installa...