Linux Notes - text editor Vim
Others
2020-02-17 14:30:41
views: null
Vim common operations
Brief introduction
- Vim is a powerful full-screen text editor, is on Linux / Unix the most common text editor. Its role is to create, edit, display text files
- Vim is no menu, only the command
- Three modes: command mode, insert mode, Edit mode
- vi filename command mode
- Enter Command Mode iao into insert mode; Insert mode ESC to return to command mode
- Enter command mode to end run
- Wq to save and exit command mode input
Insert command
- a is inserted after the character at the cursor
- A row inserted into the end of the cursor
- i inserted before the character cursor
- I first inserted at the cursor trekking
- o new line is inserted at the cursor
- O insert a new row on the cursor
Positioning command
- : Set nu set the line number
- : Set nonu cancel the line number
- gg to the first row
- G to the last line
- nG to n-th row
- : N the n-th row
- $ Move to end of line
- 0 to start of line
Delete command
- x delete the character at the cursor location
- After nx Delete n characters at the cursor
- dd Delete cursor line, ndd delete rows n
- dG Delete cursor line to the end of the file content
- D delete the content at the end of the line the cursor
- : N1, n2d delete the specified range of row
Cut and Copy command yy-p
- yy Copy current line
- Copy the following nyy current line n lines
- the current line dd
- ndd the current line n line hereinafter
- The p, P pasted in the current cursor line or row
Replace and cancel the command
- r character at the cursor substituted
- R starts replacing characters from the cursor position by the end of the ESC
- u cancel the last action
Search Search and Replace command
- / String specified search string, ignore case when searching: set ic
- n search string specified next occurrence
- :% S / old / new / g specify the replacement text string
- : N1, n2s / old / new / g replace the specified character string within a predetermined range
- g without asking; C interrogate operation
Save and Exit command
- : W Save Changes
- : W new_filename save as specified file
- : Wq to save changes and exit
- ZZ shortcut keys, save the changes and exit
- :! Q quit without saving changes
- :! Wq to save changes and exit (file owner and root can be used)
Vim tips
R + import file path
Import command execution result r! Command
Defined shortcuts map shortcuts trigger command
Continuous line comments
- : 1, 4s / ^ / # / g 1-4 first line of continuous trekking add a comment
Replace ab want to replace the contents of the replacement content
Published 61 original articles
·
won praise 6
·
views 2771
Origin blog.csdn.net/Felix_hyfy/article/details/104356849