Use of the VIM editor

Source: Internet
Author: User

Use of the VIM editor

Commands used by VIM
    • : Q Exit VI directly:
    • Wq exit VI after saving, and can create new file
    • : q! Force exit
    • : W file saves the current content as a file
    • : Set Number | NU Displays line numbers in edit file
    • : Set Nonumber |nonu does not display line numbers in edit file
VIM Move Cursor Command
    • H: Move the cursor one character to the left

    • L: Move the cursor right one character

    • Space: Move the cursor right one character

    • Backspace: Cursor moves left one character

    • K or ctrl+p: Move the cursor up one line

    • J or CTRL + N: Move the cursor down one line

    • Enter: Move the cursor down one line

    • W or W: Move the cursor right one word to the beginning of the word

    • B or B: The cursor moves left one word to the beginning of the word

    • E or E: Move the cursor right one word to the end of the word

    • 0: (note is the number 0) cursor moves to the beginning of the current line

    • $: Cursor moves to the end of the current line

VIM Flip Screen Command
    • Ctrl+u: First half screen to file

    • Ctrl+d: Half-screen to the end of the file

    • CTRL+F: Flip a screen to the end of a file

    • ctrl+b; Turn one screen to the top of the file

    • NZ: Rolls line N to the top of the screen and scrolls the current line to the top of the screen when n is not specified.

VIM Insert Text command
    • I: Before the cursor

    • I: At the beginning of the current

    • A: After the cursor

    • A: At the end of the current line

    • O: A new line below the current line

    • O: New row above the current line

    • R: Replace the current character

    • R: Replaces the current character and its characters until the ESC key is pressed

VIM Delete Text command
    • NDW or NDW: Delete the n-1 characters at the beginning and after the cursor

    • Do: Delete to the beginning of the line

    • d$: Delete to end of line

    • NDD: Deletes the current line and its subsequent n-1 rows

    • X or x: Deletes a character, x deletes the cursor, and x deletes the cursor before the

    • Ctrl+u: Delete text entered under input mode

VIM Search Replacement Command
    • /pattern: Searches for pattern at the end of the file from the beginning of the cursor

    • ? pattern: Searches for pattern from the beginning of the cursor to the top of the file

    • N: Repeat the last search command in the same direction

    • N: Repeats the last search command in the opposite direction

    • : s/p1/p2/g: Replaces all P1 in the current row with P2

    • : n1,n2 s/p1/p2/g: Replace all P1 in line N1 to N2 with P2

    • : g/p1/s//p2/g: Replace all P1 in the file with P2

Use of the 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.