How to use VIM (note)

Source: Internet
Author: User
Tags exit in

Use of the VIM editor

VI Visual Interface visual Interface VI Editor

Enhanced version of the VIM VI Improved VI editor


VIM Full screen editor, modal editor


Vim mode

Edit mode (Command mode)

Input mode

Last-line mode


Vim Open file default to edit mode, they can convert each other

The input mode and the last line mode cannot be converted directly, and need to be converted by editing mode


Mode conversion

Edit-Input

I switch to input mode in front of the character where the cursor is currently located

A is converted to input mode after the current cursor character

o Create a new row below the current cursor line and switch to input mode

I switch to input mode at the beginning of the line where the cursor is currently located

A moves to the input mode at the end of the line at which the cursor is currently located

O Create a new row above the current cursor line, and convert to input mode


Input--Edit

ESC converts the input mode to edit mode

Edit-to-last-line mode

: Enter the last line mode only from edit mode, so if you are in input mode, press ESC to go back to edit mode, then press: To enter the last line mode

Last line--edit

ESC is in the last-line mode sometimes you need to press ESC two times to get back to edit mode note



How to use:

Vim/path/to/somefile

Example: Vim/etc/inittab open/etc/inittab file with vim


First, open the file:

Vim +numer file open files and navigate to number line numbers Yes, you have to enter a number.

Vim + file open files to position the cursor to the last line,

Vim +/pattern Open the file to position the cursor to the first line that was matched to the pattern

Second, close the file:

1. Closing the file in the last line mode

: Q exit (only if you have not edited the file to exit, if you edit the file, you will be prompted that the file has been changed)

: Wq Save and exit

: q! Force quit, do not save

: W Save

: w! Forcibly saved

: wq-->:x

2. Exit in edit mode

ZZ Save exit Note is uppercase ZZ lowercase no use ha!


Third, move the cursor (in edit mode)

1. Character moving H left J down K l right

About good understanding up and down is (Japan) (Korea Korea) Map: Japan under the South Korea

If you press a number before you press these keys, you move the upper or lower left or right character or line represented by the number

Example 3j means moving down 3 rows


2. Move in Word units

W jumps to the beginning of the next word

b jumps to the beginning of the current or next word

E jumps to the ending of the current or next word

3w means jumping back 3 words to the head, you know


3. In-line jump

0 jump to the absolute beginning

^ Jump to the first non-empty character at the beginning of a line

$ jump to end of line, absolute end of line

4. Jump between rows

#G Jump to # (note that the # symbol is a number) line

G jump to the last line

In the last line mode, directly to the travel number, can also be implemented to jump to the line

Four, turn the screen

Ctrl+f Turn down one screen

Ctrl+b Turn One screen upwards

Ctrl+d Down half screen Downword

Ctrl+u turn up half screen

Not to be continued

How to use VIM (note)

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.