Use of Vim

Source: Internet
Author: User

Edit mode

Input mode

Last-line mode

1: Cursor movement between characters

H: Move one character to the left

J: Move the cursor down one character

K: The cursor moves up one character

L: The cursor moves one character to the right

If you want the line to move multiple times, such as moving down 30 rows, you can use the combination of "30j" or "30↓" to press

Plus the number of times you want to do it, press

Cursor movement between words

W: Jumps to the next word the first < the letter and the number of the continuous string, not to say the real English word

E: Jumps to the current word and the next word ending

B: Skip to current and previous word endings

In-line movement

^: Skip to the beginning of non-whitespace characters

$: Jump to end of line

0: Jump to the beginning of the line

x, x in a line of words, X is the backward deletion of a character (quite a [del] key), X is to delete a character forward (rather [backspace] is the backspace) (commonly used)

Nx:n is a number that continuously deletes n characters backwards. For example, I want to delete the 10 characters consecutively, "10x".

DD: Delete the entire column where the cursor is located (common)

Ndd:n is a number. Delete the next n column where the cursor is located, for example 20DD to delete 20 columns (common)

D1G: Delete all data from the first row of the cursor

DG: Remove all data from the last row of the cursor

d$: Deletes the cursor where the last character of the row

D0: That is 0 of the number, delete the cursor where it is, to the line and the first character

YY: The row where the cursor is copied (common)

Nyy:n is a number. Copy the down n column where the cursor is located, for example, 20yy to copy 20 columns (common)

Y1G: Copy all data from the column to the first column of the cursor

YG: Copy all data from the cursor column to the last column

Y0: Copies all data from the same character as the cursor to the beginning of the line

y$: Copies all data from the same character as the cursor to the end of the line

P, p:p to paste the copied data on the next line of the cursor, and p to stick it on the cursor line! For example, I currently have the cursor on line 20th and have copied 10 rows of data. Then press the P

, the 10 rows of data will be posted after the original 20 lines, that is, 21 lines to start. But what if we press P? Then the original 20th Guild was pushed into 30 rows. (often

With

J: Combine data from one column of the cursor in the same column

C: Delete multiple data repeatedly, such as 10 rows down, [10CJ]

U: Restores the previous action. Common

[Ctrl]+r redo the last action.] Common

This u does not [Ctrl]+r is a very common instruction! One is recovery, the other is redo.

. : Don't doubt it! This is the decimal point! is the meaning of repeating the previous action. If you want to

To repeat the deletion, repeat the paste, and so on, press the decimal point "." It's all right! Common

2: The default is the general mode, to enter the editing mode can use the following keys.

I insert before cursor

A: Insert after cursor

o: Insert a new row under the current cursor line

I: Insertion at the beginning of the line

A: End of line insertion

O: Insert a new line on the previous line of the row where the cursor is located.

R: replaces the line character of the cursor once

R: will always replace the text in the line where the cursor is located

ESC: Exit edit mode and return to normal mode.

3: General mode to instruction mode available buttons

: W writes editing data to the drive file (common)

: w! If the file property is read-only, the archive is forced to be written. However, in the end can be written, or with you on the file permissions related Ah!

: Q leave VI (common)

: q! If you have modified the file, do not want to store, use! Do not store files for forced departures. Notice that the exclamation point (!) is often "mandatory" in VI

: Wq to leave after storage, if: wq! After forcing the store to leave (common)

ZZ: This is the upper case Z Oh! If the file is not updated, then do not store away, if the file has been updated, then save and leave!

: w [filename] saves editing data to another file (similar to saving new files)

: R [FileName] in the edited data, read into another file data. The file "filename" will be added to the cursor row after the

: n1,n2 w [filename] stores the contents of N1 to N2 as the filename file.

:! Command temporarily leaves VI to command column mode to perform command display results! For example ":! Ls/home "You can see in VI the file information under/home with LS output!

Changes to the VIM environment

: Set NU Displays the line number, which, when set, displays the line number in each row prefix

: Set Nonu not set Nu instead, the line number is canceled!

Use of Vim

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.