Linux Command---Vim

Source: Internet
Author: User
Tags switches

General mode: Open a file with vim directly into the general mode, in this mode, you can use the left and right buttons to move the cursor, you can delete characters or delete the positive row, you can copy, paste text data.

Edit mode: In general mode, press "I,i,o,o,a,a,r,r" and any one of the letters into the editing mode, in edit mode, press the "ESC" button to exit edit mode.

Command line mode: In general mode, enter ":,/,?" "Any one button, you can move the cursor to the bottom row." In command-line mode, you can perform operations such as saving, leaving Vim, and so on.

Examples are as follows:

1.vim test.txt Create test.txt text file

If the new file is opened, it will appear as follows:

2. Press I to enter edit mode to start editing text

3. Press "ESC" back to normal mode

4. In the general mode, enter ": Wq" after saving to leave vim

The following buttons are available in general mode:

h or LEFT ARROW key to move one character to the left

J or DOWN ARROW key cursor moves down one character

K or up ARROW key to move the cursor up one character

L or RIGHT ARROW key cursor move one character to the right

Ctrl+f screen moves down one page

Ctrl+b screen Move up one page

/word down looking for a string called word

: 1, $s/word1/word2/g finds the word1 string from the first row to the last line and replaces the string with Word2

X,x in one line, X is to remove a character backwards, and X to delete one character forward

DD Delete the entire line where the cursor is located

YY the line where the cursor is copied

P,p p Pastes the copied data on the next line of the cursor, and P is pasted on the cursor line

U Restore previous action

Ctrl+r Redo Last Action

. Repeat the previous action, if you want to repeat the deletion, repeat the paste operation, press the decimal point to

General mode switches to the available buttons in edit mode:

I,i into insert mode: I is inserted from the current cursor, I is the first non-whitespace space in the row to start inserting

A,a into insert mode: A is inserted from the next character at the current cursor, a is inserted from the last character of the line where the cursor is located

O,o into insert mode: O inserts a new line at the next line where the cursor is currently located, O inserts a new row at the previous line where the cursor is currently located

R,r into insert mode: R replaces only the character of the cursor at a time, and r always replaces the text of the cursor until the ESC key is pressed

[ESC] Exit edit mode, return to normal mode

General mode switches the available buttons to the command-line mode:

: W writes the edited data to the hard drive file

: Q Leave Vim

: q! If you have modified a file and do not want to store it, use "!" Do not save files for forced leave

: Wq left after saving

: wq! Forced to leave after saving

ZZ If the file has not changed, then do not save leave, if the file changed, then left after saving

Linux Command---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.