Vim Editor
Text editor, word processor ASCII
Full screen editor, modal editor
Vim mode
Edit mode (Command mode)
Input mode
Last-line mode
Mode Conversion:
Edit-Input
I: Convert to input mode in front of all characters in the current cursor
A: After all the characters in the current cursor, convert to input mode
O: Create a new row below the current cursor line, and convert to input mode
I: Convert to input mode at the beginning of all characters in the current cursor
A: Convert to input mode at the end of all characters at the current cursor
O: Create a new row above the current cursor line and convert to input mode
Input--edit: Esc
Edit-to- last line::
last line--edit: Esc
First, open the file
# Vim/path/to/somfile (Must have home directory)
File exists: Edit content, do not exist, create this file and edit content
Vim +#: Open the file and locate it on line #
Vim +: Open file, position on last line
Vim/pattern: Open the file and navigate to the line that was first matched by PATTERN
Second, close the file
1. In the last line mode
: Q exit
: Wq Save and exit =:c
: q! do not save and exit
: W Save
: w! forcibly saved
2. Edit mode
ZZ: Save and exit
third, move the cursor (edit mode)
1. Character-by-word movement
H: Left
L: Right
J: Down
K: Up
#h: Moving a # character
2. One word for unit moved to
W: Move to the beginning of the next word
E: The ending of the current or next word
B: Tune to the beginning of the current or previous word
#w: Move to the beginning of a # Word
3. In-line jump
0: The absolute beginning
^: first non-whitespace character at the beginning of a line
$: absolute end of line
4. Jump between rows
#G: Jump To Line #
G: Last line
In the last line mode, directly to the travel number can be
Four, turn the 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
v. Delete a single character
X: Delete a single character at the cursor location
#x: Remove the total # characters from the cursor and backwards
vi. Delete command: D
The D command is used in combination with the jump command
#d跳转符: Remove the # number for the specified range of jump characters
#dw, #de, #db
DD: Deletes the current cursor in the row
#dd: Delete the line of the current cursor
d$: Delete the current cursor to the end of the line content
D0: Delete the current cursor to the beginning of the content
In the last line mode:
Start line, end row
.: Indicates when the forward
$: Last line
$-1: pour two rows
+#: Down # line
Seven, Paste command
Small P: If you delete or copy the entire line, paste it below the line where the cursor is located
If it is not an entire row, paste to the back of the character where the cursor is located
Big P: If you delete or copy the entire line, paste it above the line where the cursor is located
If it is not an entire row, paste to the front of the character where the cursor is located
viii. Copy command: Y
Usage with d command
The y command is used in combination with the jump command
#y跳转符: Copy a jump character to a specified range of # numbers
#dw, #de, #db
YY: Copy the current cursor in the row
#yy: Copy the # line of the line where the current cursor is located
y$: Copy the contents of the current cursor to the end of the line
ix. Modification: delete content First, then convert to input mode
Usage with D
The C command is used in combination with the jump command
#c跳转符: Remove the # number for the specified range of jump characters
#cw, #ce, #cb
CC: Modifies the current cursor in the row
#cc: Modify the # line of the current cursor line
C $: Modifies the current cursor to the end of the line
10. Replace
#r: Replace the following # characters
11. Undo Edit Operation U
U: Undo the previous edit operation
Continuous U-Bar command to undo previous N Edit operations
#u: Undo Recent # Commands (up to 50 times)
Restore the most recent undo Operation Ctrl+r
12, repeat the previous edit operation:.
13. Visualization Mode
V: Select by character
V: Select by rectangle
14. Find
/pattern
? PATTERN: Looking backwards from the current cursor line to the file header
-N Previous
-N Next
15. Find and replace
Use the S command in the last-line mode
ADDR1,ADDR2 [email protected] @string
/pattrnl/,/pattern2/
The first line that was pattrn1 matched to the end of the line to which the first match was pattrn2, all the rows in the middle
s/pattern/string/modifier: Find pattern (available regular expression) and replace with string
(The default is to replace only the first string in each row that is matched to the pattern)
G: Global Substitution
I: Ignore case when finding
16. Use Vim to edit multiple files:
Vim FILE1 FILE2 FILE3
: Next switches to the next file
:p Rev Switch to the previous file
: Last switch to final file
: first to switch to file one
: QA Exits All Files
17, split screen display a file
Ctrl+w Press S: Split window horizontally
Ctrl+w Press V: Split window vertically
Toggle cursor in Widget:
Press arrow (left and RIGHT arrow) after Ctrl+w: Toggle left and right side window
: QA Closes all windows
18. Edit multiple Files in a window
Vim-o: Horizontal Split display
Vim-o: Vertical Split display
19. Save some of the contents of the current file as a different file
: w command in last row mode
: Addr1,addr2w/path/to/somewhere: Save to specified file
20. Populate the current file with another file
: R/path/to/somefile
21. Interacting with the shell
:! command to go back to the screen to execute the commands (view file Eg:ls xx. Enter back Vim editor)
22. Advanced Topics
1. Display or suppress line numbers
: Set number Displays line numbers
: Set NU Displays line number
: Set Nonu does not display line numbers
2. Display ignores or distinguishes character case
: Set ignorecase
: Set IC
: Set Noignorecase
3. Set Auto indent
: Set Autoindent
: Set AI
: Set Noai
4. Find text up to this display or cancel
: Set Hlsearch
: Set Nohlsearch
This article is from the "11160930" blog, please be sure to keep this source http://11170930.blog.51cto.com/11160930/1757976
2016-3-29 the use of the Linux Basic Learning--vim Editor