Vim's detailed use

Source: Internet
Author: User

Vim Editor:;
Full-screen editor: Vim:vi Improved (vi enhanced version)
Vi:visual interface
Vim: Just text full screen editor
Pattern:
Edit mode: Also called command mode to copy the text, delete and so on
Input mode: That is, enter content into the text
Last-line mode:
Edit mode--Input mode:
I:insert inserted at the current cursor position
A: Insert at the rear of the cursor
O: Add a new line below the line where the cursor is located
I: Insert at the beginning of the line where the cursor is located
A: Insert at the end of the line where the cursor is located
O: Add a new row above the line where the cursor is located

Input mode--edit mode
Esc

Edit Mode--last-line mode

Last-line mode--edit mode
Esc
Open VIM:
Vim/path/to/somefile
+#: #为行号: The cursor is at the beginning of the # line when Vim is turned on
+/pattern:: When Vim is turned on, the cursor is at the first line that matches the PATTERN
Turn off VIM
: Q
: q!
: Wq

Cursor Jump:
Jump between characters:
H: Jump to one character to the left
L: Turn Right one character
J: Jump down one character
K: Jumps up one character

#COMMAND

Jump between words:
W: Jump to the ending of the last word
E: The ending of the current or subsequent word
B: The first word of the current or previous word

#COMMAND

In-line jump:
^: jumps to the first non-whitespace character at the beginning of a line
0: Jump to the absolute beginning
$: Jump to absolute end of line

Move between rows:
#G: Jump To Line # beginning

Edit command:
Character editing:
X: Delete the character at the cursor location
#x: Delete the start of the cursor at the beginning of the # characters

Xp:

R: the character at which the cursor is replaced

Delete command
D: Delete the character that the cursor moves through (often used in conjunction with the cursor jump command)
D^,d$,d0,dw,de
DD: Delete the entire line of the line where the cursor is located
Note: Deleted content is saved in the buffer by the VIM editor

Paste:
If this copied or deleted content is not a full line
P: Paste until the current cursor is located at the back:
P: Paste at the front of the current cursor:

If this copied or deleted content is a full line (more than one line)
P: Paste to the next line where the current cursor is located:
P: Paste to the previous line where the current cursor is located;

Copy command:
Y usage is the same as deleting

Change command

Undo the previous Edit command
U:undo
To undo an earlier edit operation:

Ctrl+r Restore the previous undo U operation
Turn screen operation:
Ctrl+f Back one screen
Ctrl+b forward one screen
Ctrl+d Back half screen
Ctrl+u: Forward half screen

Vim's last-line mode
(1) Address: delimitation
: Start_pos,end_pos
#: Line #
#,# Absolute number of rows
#,+# the absolute number of rows, with the relative number of rows
.: When moving forward
$: Last line
%: Full text

/PART1/: The row that was first matched to

After you can follow the edit command:
D,y
W,r
(2) Find
/pattern: Looking at the tail
? PATTERN: Searching to the header
N: Indicates the command looks for the next in the same direction
N: Indicates that the command looks in the same direction for the previous
(3) Find and replace
S: In the last line mode, the search and replace operation is done within the bounds of the address;

s/what to look for/replace with content/modifiers
What to look for: You can use regular expressions, can be used after the "Replace with" the "&" all references,
Replace with: You cannot use a regular expression, but you can use the back shadow symbol

Modifier:

I: Case insensitive when looking for characters

G: Global Substitution

/: Used as a delimiter to split the "what to find" and "Replace with content" This delimiter can use other symbols such as: @,#.
Multi-file Mode:
Vim file1 file2 ...
: Next
: First
: prev
: Last


Multiple window split modes:
Vim-o Split multiple windows horizontally
-O split multiple windows vertically
Single File Window segmentation:
Ctrl+w s: Horizontal split
Ctrl+w,v Vertical Segmentation
Some of the working features of the custom vim:
1 line number
Display: Set Nu
Disabled: Set Nonu
2 Bracket Matching
Display: Set SM
Disabled: Set NOSM
3 Auto Indent
Set AI
Set Noai
4 Highlight Search
Set Hlsearch
Set Nohlsearch

Vim's configuration file

Global:/ETC/VIMRC

Personal: ~/.VIMRC

Executing commands and importing files in vim

In the last line mode:

Import File: R FILENAME

Execute command:! COMMAND

Results of Import execution command: r! COMMAND

Vim's detailed use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.