first, the common operation(i) Vim mode of operation
1.VIFile: Enter Command mode 2,Iao: Enter insert mode
- ESC: Exit Insert, enter command mode
3, ":": Enter edit mode
- Enter: End run, enter command mode
5.Wq: Exit
(ii) command 1, insert command:AIO
- A: Insert the word specifier the cursor
- A: Insert at the end of the line where the cursor is located
- I: Insert the word match either in the cursor position
- I: Insert at the beginning of the cursor
- o: Insert a new line under the cursor
- O: Insert a new line on the cursor
2. Positioning command:
- : Set Nu: Sets line number
- : Set Nonu: Cancel line number
- GG: to the first line
- G: to the last line
- NG: to Nth row
- : N: to Nth row
- $: Move to end of line
- 0: Move to the beginning of the line
3. Delete command
- X: Delete the character at cursor location
- NX: Delete the n characters after the cursor is located
- DD: Delete Row of cursor, NDD delete n rows
- DG: Delete the line from the cursor to the end of the file
- D: Delete the cursor at the end of the line
- : n1,n2d: Delete the specified range of rows
4. Copy and Cut commands
- YY: Copy when moving forward
- Nyy: Copy the current row following n rows
- DD: cut when moving forward
- NDD: Cuts the current row following n rows
- P, p: Paste
5. Replace and Cancel commands
6. Search and Replace commands
- Set IC and set Noic
- %s: full-text replacement
- Start line, terminating line substitution
- g do not inquire; C-Inquiry
7. Save and exit
- ZZ: Save changes and exit
second, the use of skills1. Import command Execution results
- : r "file name"
- :! LS: Execute the LS command without exiting the edit
- : R! Date: The result of date execution can be imported into the currently edited text
2. Define shortcut keys
- map"shortcut key" "Trigger command"
- Map ^p i#<esc>: Add comments
- Map ^b 0x: Delete comments
- Map: ^h [email protected]<esc>: Insert email address
- ^:ctrl V
3, Continuous line comment
- : n1,n2s/^/#/g
- : 1,4s/^/#/g,1 to 4 lines add # comment
- : 1,4s/#//g, remove #
- : n1,n2s/^#//g, get rid of the beginning #
- : n1,n2s/^/\/\//g
- 1,4s/^/\/\//g, beginning Add//comment
4. Replace
- : AB mymail [email protected]
5.configuration of shortcut keys is written: 1) Address:
- /root/.vimrc
- /home/sam/.vimrc
2) operation
- Direct Write command
- Set Nu
Linux Basics (iv): text editor vim