Vim editing instruments

Source: Internet
Author: User
Tags line editor

(i) Vim editor

  • Text Editor: Plain text, ASCII text;unicode, no HTML, or metadata such as formatting tags in Word documents
  • Type of text editor
    • Line Editor: SED
    • Full Screen Editor: Nano,vi,vim
  • Vi:visual Interface
  • Vim:vi improved
    • Patterned Editor
      • Edit mode/Command mode
      • Input mode
      • Last-line mode
        • Built-in command-line interface
    • Open File
      • If the file does not exist locally, the file is created
      • Vim [OPTIONS] [File ...]
      • The cursor is automatically at the beginning of the first line
      • +#: After opening the file, the cursor is automatically at the beginning of line #, for example: Vim +5 fstab
      • +/pattern: After opening the file, just leave the cursor at the beginning of the first line that is matched by PATTERN, for example: Vim +/if functions
      • +: Automatically at the beginning of the tail line, for example: Vim + fstab
    • Mode conversion
      • Edit mode: Default mode
      • Edit mode--Input mode:
        • I:insert, enter at the cursor position
        • A:append, enter at the rear of the cursor
        • O: Add a row below the cursor at the beginning of the line
        • I: Uppercase I means insert at the beginning of the line where the cursor is located
        • A: Insert at the end of the line where the cursor is located
        • O: Add a line at the top of the cursor at the beginning of the position
      • Input mode--edit mode:
        • ESC key
      • Edit mode--and last-line mode:
        • : Key
      • Last-line mode--edit mode:
        • Press the ESC key two times in a row
      • cannot be from input mode to last row mode
    • Close File
      • In edit mode, press two capital Z consecutively to save and exit
      • In the last line mode
        • Q: Exit, the file must not be modified
        • Q! : Force quit, do not save previous edits
        • WQ: Save and exit, two commands can be written separately
        • X: Save and exit
        • W FILENAME: Save As
    • Cursor Jump
      • Jump between characters
        • H: One character to the left
        • L: one character to the right
        • J: one character down
        • K: one character up
        • #COMMAND: Jump # Characters
      • Jump between words
        • W: The first word of the next word
        • B: The first word of the current or previous word
        • E: The ending of the current or next word
        • #COMMAND: Jump # words
      • Beginning line End Jump
        • ^: jumps to the first non-whitespace character at the beginning of a line
        • 0: Jump to the absolute beginning of the line (does not include the TAB key?? )
        • $: Jump to absolute end of line
      • Inline jump
        • #G: Jump to the beginning of line #
        • 1g,gg: Jump to the first line
        • G: Jump to the last line
      • Jump between sentences
        • ): Skip to next sentence
        • (: Jump to the previous sentence
        • #COMMAND: Jump # sentence
      • Jump between segments
        • }: Skip to next paragraph
        • {: Skip to previous paragraph
        • #COMMAND: Jump # Segment
    • Flip Screen operation
      • CTRL+F: Flip a screen to the end of the file
      • CTRL+B: Flip a screen to the file header
      • Ctrl+d: Turn half screen at the end of the file
      • Ctrl+u: Turn half screen to file header
      • Enter: Turn backward by line
    • Vim's editing commands
      • Character editing
        • X: Delete the character at the cursor location
        • #x: Delete The total # characters at and after the cursor
        • XP: Swap the position of the character and the following character at the cursor location
      • Replace command
        • Rchar: The character at which the replacement cursor is a char character
      • Delete command
        • D: Can be combined with the cursor Jump command, to achieve range deletion
          • d$: Delete the contents of the cursor at the end of the line
          • d^: Delete the contents of the cursor at the beginning of the line
          • Dw,de,db, ...
          • #COMMAND: Delete #, for example: 3DW
          • DD: Delete an entire row of the cursor row, also support #dd, for example: 3DD means delete 3 rows
        • The deleted content is saved in the buffer, and the last deletion can be used to paste
      • Paste command
        • P: The contents of the buffer are pasted at the bottom of the line where the current cursor is located, if the entire row is the same; otherwise, paste at the rear of the current cursor
        • P: The contents of the buffer are pasted at the top of the line where the current cursor is located, if the entire row is the same; otherwise, paste at the front of the current cursor
      • Copy command
        • Y: Work behaves similar to D command
        • YY: Copy entire row
      • Change command
        • C: Perform the delete operation first, as in the D command, and then immediately transfer from edit mode to input mode
    • Visualization mode
      • V: Selected by character
      • V: Selected by row
      • Combined with edit command: d,c,y
    • Undo Action
      • U: You can generally undo the last 50 operations
      • #u: Undo Previous # Operations
    • Revert to previous revocation
      • Ctrl+r
    • Repeat previous action
      • .
    • Vimtutor command to open the VIM tutorial

Note: the "100,2-9 14%" displayed in the lower right corner represents the 100th page, the 2nd valid character, the 9th absolute character, the content of 14%; (a tab character representing 8 absolute characters)

Vim editing instruments

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.