Use of VIM commands

Source: Internet
Author: User

March 2016 record
command line editing system
DD Delete a row
NDD Delete multiple lines

DW Delete a Word
NDW delete multiple words
Daw Delete a word, cursor in any position

DGG Delete all previous words
DG Delete all the words behind
U undo

d^ Delete to the beginning of the line
d$ Delete to the beginning of the line

YY Copy a row
Nyy Copying multiple lines
P Paste

Visualize operations
Visual Selection Shift+v
Visual Block Check Control+v

Shear
Shift +v then press D and then paste P

Move:
Number means to navigate to number row
GG positioning to the start position
G Anchor to end position
H Move one cursor forward
J Move down one standard
K
L

Enter edit mode:
I is the one that is inserted before the cursor position
I means the first line of the cursor is inserted
o indicates the next line inserted at the cursor location
o indicates the line inserted at the cursor location
s = Replace text
S
A
A
Command-line mode:
: W means save
: Q indicates exit
: q! Forced exit
: Wq Save and exit
: W means Save As
: R!cat/etc/passwd means get external file
: R!sed-n "3,6p"/etc/passwd indicates

Display multiple Files
vim-0 Filenamel filename2 .... felemnamen
Switch between files

Vim:
Program Developer

Vim:vi
Vim: View VIM version
Editor
Compiler: GCC
Vim filename: Open a vim

Viewing file types: Files + filename

Three modes:
General mode: Open file mode directly by default
Edit mode: Insert in the lower left corner indicates entry into edit mode
Command-line mode: In the lower-left corner: The typeface indicates a command-line mode

Switch:
General mode switch to edit mode
I i o O s s a A
Edit mode Toggle command line mode:
ESC-: cmd

General mode:
Delete:
DD: means to delete a row
NDD: means to delete n rows

DW: Delete A word cursor at the first character
NDW: Delete multiple words
Daw: Delete A word cursor can be anywhere

DGG: Delete the line of the cursor to the beginning of the file
DG: Delete the line of the cursor to the end of the file
U: Undo Last Action

d^: Delete to line start
d$: Delete to end of line

Copy:
YY: means copying a row
Nyy: means copying multiple lines
P: Paste


Visualize operations
Visualize lines: Shift + V-P
Visual characters:
Visualization Block: Control + V
Shear:
Shift + V, D-P
Move:
Direction key
: Number: Indicates positioning to number row
GG: Indicates the beginning of a file
G: Indicates end of file
H: Move one to the left
J: means moving down one
K: means move up one
L: To be entitled to move one

Edit mode:
I i o O s s a A

I: Indicates that the cursor is inserted before
I: Indicates the first insertion at the cursor line
O: Indicates the next line where the cursor is inserted
O: Indicates the line where the cursor is inserted
S: Indicates replacement of the current character insert
S: Represents the replacement of the current row insert
A: Indicates the insertion after the character of the cursor
A: Indicates insertion at the end of the line at the cursor

Command-line mode:
: W means save
: Q indicates exit
: q! Indicates forced exit
: Wq means save and exit
: w filename means Save As
: R!cat/etc/passwd means getting external file contents
: R!sed-n "3,6p"/etc/passwd for 3 to 6 rows of content
: Set number indicates that line numbers are displayed for temporary effect
Permanent effect Modify VIM configuration file
~/.vimrc
Set Nu
: Set Nonu indicates the row number is canceled
: Set IC indicates case insensitive
Note: "

Select Shift + > to move right
SHIFT + < to move left

Display multiple Files
Vertical cut: vsplit filename
Vim-o filename1 filename2 ... filenamen
Switch between files control + W (2 times) Ctrl + W
Save all exit:: WQA
Horizontal cut split filename
Vim-o filename1 filename2 ... filenamen

Find:
:/key
n means to switch between the found keywords from top to bottom to find
N means find from bottom to top
:? key

Replace:
: Range S/oldkey/newkey/option
Range:
N,m: Indicates substitution from Nth line to M row
%: Full text
1,$: Express Full text
Parameters:
g = Replace All
I means case-insensitive substitution

\: Represents the escape character

: X Encryption
: Set key=


Use of VIM commands

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.