Vim Editor
Text editor, word processor
Ascii
Nano, SED
Vi:visual Interface
Vim:vi Improved:vi the basics plus some useful plugins
Full screen editor, modal editor
Vim mode:
Edit mode (Command mode)
Input mode
Last-line mode
Mode conversion:
Edit--Input:
I: In front of the character of the current cursor, switch to input mode;
A: After the character of the current cursor, switch to input mode;
O: At the bottom of the current cursor line, create a new row and switch to input mode;
I: Converted to input mode at the beginning of the line at which the cursor is currently located
A: At the end of the line where the current cursor is located, convert to input mode
O: Create a new row above the current cursor line and switch to input mode
Input-to-edit:
Esc
Edit-to-last line
:
Last line--edit:
ESC, ESC
An open file
# Vim/path/to/somefile
Vim +#: Open the file and locate it on line #: Vim +12 Rc.sysinit
Vim +: Open file, navigate to last line: Vim + rc.sysinit
Vim +/pattern: Open the file and navigate to the beginning of the line that was first matched to the PATTERN: Vim +/know rc.sysinit
Default in edit mode
Two close files
1. Closing the file in the last line mode
: Q exit
: Wq Save and exit
: q! Do not save and exit
: W Save
: w! Forcibly saved
: Wq---: X
2. Exit in edit mode
ZZ: Save and exit
Three. Move cursor (edit mode)
1. Character-by-word movement:
H: Left
L: Right
J: Next
K: Up
#h: Move # characters; : 4h
2. Move in Word units
W: Move to the beginning of the next word
E: Jumps to the ending of the current or next word
B: Jump to the beginning of the current or previous word
#w: 4w
3. In-line jump:
0: The absolute beginning
^: first non-whitespace character at the beginning of a line
$: absolute end of line
4. Inter-row Jump:
#G: Jump to Line #;
G: Last line
In the last line mode, directly to the travel number can be
Four. Flip Screen
CTRL + F: Flip one screen down
CTRL + B: turn up one screen
CTRL + D: Flip down half screen
CTRL + U: Flip up half screen
Five. Delete a single character
X: Delete a single character at the cursor location
#x: Remove the total # characters from the cursor and backwards
Six. Delete command: D
The D command is used in combination with the jump command;
#dw, #de, #db
DD: Deletes the current cursor in the row
#dd: Delete the line containing the line of the current cursor;
In the last line mode:
Startadd, ENDADDD
. : Indicates when the forward
$: Last line
+#: Down # line
Seven. Paste command P
P: If you delete or copy to an entire row, paste to the bottom of the line where the cursor is located, and if the copied or deleted content is a non-full row, paste it after the character that contains the cursor
P: If you delete or copy to an entire row, paste to the top of the line where the cursor is located, and paste to the front of the character where the cursor is located if the copied or deleted content is not a whole line
Eight. Copy command y
Usage with d command
Nine. Modify: Delete content first, then convert to input mode
C: Usage with d command
10. Replace: R
R: Replacement mode
Eleven. Undo Edit Operation U
U: Undo the previous edit operation
Continuous U-command to undo previous N Edit operations
#u: Undo Recent # edits directly
Undo the last Undo operation: Ctrl + R
Twelve. Repeat the previous edit operation
. Point command repeats an edit operation
13. Visualization mode
V: Select by character
V: Select by rectangle
14. Find
/pattern
? PATTERN
N
N
xv. Find and replace
Use the S command in the last-line mode
ADDR1, [email protected]@[email protected]
1,$
%: Full text
Exercise: Replace Ftp://instructor.example.com/pub in the/etc/yum.repos.d/server.repo file with Http://172.16.0.1/yum
Vim opens the file in the last line mode:
%s#ftp://instructro.example.com/pub#http://172.16.0.1#gi
16. Use Vim to edit multiple files
Vim FILE1 FILE2 FILE3
: Next switches to the next file
: prev Switch to previous file
: Last switch to final file
: first to switch to file one
Exit
: QA All exits
17. Split-screen display of a file
Ctrl + W, s: Split window horizontally
Ctrl + W, V: Split window vertically
Toggle the cursor between windows:
Ctrl + W, ARROW
: QA Closes all windows
18. Edit multiple files in a split window
Vim-o: Horizontal Split display
Vim-o: Vertical Split display
Nineteen. Save some of the contents of the current file as a different file
Use the W command in the last row mode
: W
: Addr1,addr2w/path/to/somewhere
Twenty. Fills the contents of another file in the current file
: R/path/to/somefile
21st. Interacting with the shell
:! COMMAND
22. Advanced Topics
1. Display or suppress line numbers
: Set Number
: Set Nu
Set Nonu
2. Display ignores or distinguishes character case
: Set ignorecase
: Set IC
: Set Noic
3. Set Auto Indent
: Set Autoindent
: Set AI
: Set Noai
4. Found text highlighting or canceling
: Set Hlsearch
: Set Nohlsearch
5. Syntax highlighting
: Syntax on
: Syntax off
23. Configuration file
/etc/vimrc
~/.vimrc
No new hidden files can be created in the current user home directory:. VIMRC
Vim:
Linux--vim Editor