Vim Learning Note (1)--vim operation

Source: Internet
Author: User
Tags save file

Only some of the VIM operations that you use most often are recorded. Keep up to date

Text manipulation
    • D cut. Double-click to cut a row
    • Y copy, double-click to copy a row
    • P Paste

    • x Delete the character below the current cursor

    • R replaces the current cursor character. Replace the character in the back

    • : s/old/new/g global replace old to new

Move
    • 0 move to the beginning
    • $ move to end
    • W moves to the beginning of the next word
    • E moves to the end of the next word

    • The first X-letter position after FX moves to the bank

    • TX moves to the first position of the previous X-Letter after the bank

    • GG jumps to the top of the file

    • G jump to end of file
    • NG to the nth row, or by: N can also be

    • {Last paragraph. } Next Paragraph

    • % jumps to match the parentheses at the

    • Ctrl+o Previous Location

    • Ctrl+i Next Position

Text movement and manipulation are used in conjunction with each other. For example, d$+enter Delete to the end of the line, DW Delete to the next word, 2DD delete the next two lines

can also be used with the numbers, for example Y+ENTER5, copy the following 5 lines,: 1,20d+enter Delete 1~20 Line

Mode Toggle Insert Mode
    • I enter insert mode. Current insertion cursor Position insertion
    • A enters insert mode, the next cursor position is inserted
    • O into insert mode, inserting a line below the current line
    • O Enter insert mode. Inserts a row on the current line

Configurable vim to mouse cursor positioning mode

Visualization mode
    • : V Enters visualization mode
Replacement mode
    • : R enters replacement mode
Using external commands
    • :! Join the external command after!
Find
    • :/ Add what you're looking for in/after

When you go to find. Press N to find the next, N to find the previous

File Operation Save File
    • : W Save
    • : SaveAs filename Saved as
Exit
    • : Q
Save Exit Vim

Vim Save exit: X and: Wq difference. For example, the following:
: Wq and ZZ are forced to write files and exit (save and exit Write%quite). Force writes even if the file has not been altered. and update the file's change time.
: X writes the file and exits. Write only when the file is changed and update the file change time. Otherwise, the file churn time is not updated.

There's nothing different about the two in general, but in terms of programming, editing the source file can have a significant impact. Because the file is not changed, ": Wq" forces the update of the file's change time. This will allow make to compile the entire project and assume that the file has been altered. Then you have to compile the link again to run the executable file.

This can have misleading consequences. Of course, there are unnecessary costs of system resources.

Operation Fallback and Redo
    • U Undo Last Change
    • U Undo the changes we have made
    • Ctrl+r Redo Operation
Other
    • Ctrl+g displaying current file information
    • Ctrl+d Complete command

References:

    • Vmtutor
    • Http://coolshell.cn/articles/5426.html

Vim Learning Note (1)--vim operation

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.