Basic usage of VIM editor

Source: Internet
Author: User
Tags linux text editor

Basic usage of VIM editor

Vim is the upgrade version of VI, the function is very powerful, is currently the mainstream Linux text editor. Its configuration file is saved in/ETC/VIMRC

The VIM editor has three modes of operation: command-line mode, input mode, and last-line mode.

The transitions between them:

Command mode, input mode I i a a o O

I means to enter the input mode before the cursor position

I for Input mode at the beginning of the line where the cursor is located

A indicates the input mode after the cursor position

A indicates that the line at the end of the cursor is converted into input mode

o indicates the insertion of a new line below the line of the cursor into the input mode

O indicates that a new line is inserted above the line of the cursor into the input mode


Input mode, command mode just press the ESC key

Command mode, last line mode by: Wq or x means save exit q! Indicates that a forced exit Q is not saved to exit

Command-line mode:

W means jump to the next word head

E means jump to the end of the next word

h means the cursor moves to the left

L means the cursor is moving to the right

J means the cursor moves down

K indicates the cursor is moving up

0 indicates that the cursor jumps to the beginning of the line absolute

^ indicates that the cursor jumps to the first character of the line where the cursor is located relative to the beginning

$ means jump to the end of the line where the cursor is located

Y means copy p to paste

YY means that the copy cursor is in line with a whole line yw means that the copy cursor is in the phrase 3yw means to copy three consecutive phrases

DD indicates the deletion of a row of the cursor with a whole line of 3dd means a duplicate delete cursor down three whole line DW 3DW

U means undo last action U means undo last undo operation

X represents the deletion of the character of the cursor NX means the deletion of the characters in the cursor with the second n characters n=2 3 4 5 6 .....

R = Replace cursor such as: RQ means replace the character of the cursor with Q

V indicates a visual selection v means a visual selection of a rectangle



Last-line mode:

Press the: Number in command-line mode to turn to the last-line mode

Enter the set nu in the last line mode to display the line number, if you need to automatically add the line number each time, you need to modify the configuration file

/ETC/VIMRC Add set Nu Save to exit to take effect.

10 indicates that the cursor jumps to line 10th

10d means delete line 10th

1,10d to delete lines 1th through 10th

10s/x/y means to replace the first match of the 10th line with the X y

10s/x/y/g means to replace the X in line 10th with the Y-Note: G is a representation of the global

Q means exit W means save! Represents a mandatory

QW means save exit q! Indicates forced exit












This article is from the "self-confidence Persistent" blog, please be sure to keep this source http://6311892.blog.51cto.com/6301892/1692317

Basic usage of VIM editor

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.