Vim usage Summary

Source: Internet
Author: User

Vim usage Summary
Vim is a well-known powerful and highly customizable Text Editor similar to Vi. It improves and adds many features based on Vi. VIM is pure free software in three general modes: vim opens a file and enters the general mode. Move the cursor in this mode to delete characters or rows. You can copy or paste file data. In edit mode, enter the following key to enter edit mode: I: insert, insert a: append, o: new line, I: line first A: line End O: at the end of the New Construction Bank, the moving characters of the vim operation cursor are displayed. Jump to hjkl-> upper left, lower left, and upper right. The direction keys can also jump between words: w: The first word e: the end of the current or next word; B: the beginning of the current or previous word; # COMMAND: In-line jump: ^: Jump to the first non-blank character at the beginning of the line; 0: jump to the beginning of the line; $: jump to the end of the line; move between lines: # G: 1G, move between gg G sentences:) (move between paragraphs :} {edit operation character editing command: X: large X: deletes a character from the forward, which is equivalent to deleting a character from the Backspacex: lowercase x, which is equivalent to del # x: delete the cursor to the back # character xp: The character at the cursor and the next character position to adjust the DELETE command: d: d ^ Delete All characters from the cursor position to the beginning of the line d $ Delete All characters from the cursor position to the end of the line d0 Delete the cursor position To all the characters at the beginning of the line dG: delete all the characters d1G from the cursor to the last line: delete all the characters dd from the cursor to the first line: Delete the row where the cursor is located # COMMAND note: the deleted content will be saved to the buffer by the vim editor and pasted with the command: p (paste, put). If the copied or deleted content is not a complete row: p lower case: paste to the front of the current cursor P capital: paste to the front of the current cursor if the copied content is a complete line (more than one line) p lower case: paste to the bottom of the current cursor row P capital: paste to the top of the current cursor row Copy command: y, yanky: yy: copy the row where the cursor is located # yy: copy the cursor down # Row y1G: copy the row where the cursor is located to all characters in the first line yG: Copy all characters in the row where the cursor is located to the last line y $: copy all characters from the character of the cursor to the end of the line y ^, copy all characters from the character of the cursor to the beginning of the line. Command: c, change both file editing and Mode Conversion c $, c ^, c0, cb, ce, ce, cwcc: Delete the row where the cursor is located and move to insert mode to remove Previously edited by undo: undo unedited by undo # uCtrl + r unedited by undo.: repeat one edit operation to flip the screen. Operation: Ctrl + f: screen flip down one page Ctrl + B: screen flip up one page Ctrl + d: screen move down half page Ctrl + u: the screen moves the last row of the half-page to the upper part of the page: (1) Address, demarcation: start_pos, end_pos #: line #, #: from line # To line #, + #: from # Row to # + # Row.: current row $: the last row of the group %: full text, equivalent to 1, $/pat1/: the row that is matched by this mode for the first time; #,/pat1 /: starting from #, the line/pat1/,/pat2/That is matched by this pattern for the first time /: the line that is matched for the first time in this mode can be followed by the edit command: y, w, r (2) Find/PATTERN: search to the end? PATTERN: Search for n from the header: N in the same direction as the command: n in the opposite direction of the command (3) search and replace s: in the last line mode, complete the search and replacement operations within the scope of the location-specific domain. s/content to be searched/content to be replaced/modifier content to be searched: Content in the available mode to be replaced: unavailable mode, however, you can use the backward reference symbol to reference the content matched by the grouping brackets in the preceding mode; \ 1, \ 2 ,... &: reference the entire content matched with "content to be found". modifier: I: case-insensitive g: Global replacement c: prompt to confirm whether to replace/: Used as separator, therefore, if this symbol is displayed in the content to be searched or replaced, escape it with "\" and use the format: \/separator to replace it with other characters, such as "@" and; multi-file mode: vim FILE1 FILE2...: n edit next file: N edit previous file: files list all files currently opened by vim: next edit next file: first edit first file: prev edit previous file: last edit the last file: wq All save and exit all open files: q! All force exit all open files multi-file window split: vim-o |-O FILE1 FILE2... ctrl + w, ARROW (ARROW) switch window single file window split: Ctrl + w, s: split, horizontal split Ctrl + w, v: vertical, some features of vertical segmentation custom vim: (1) row number display: set nu disabled: set nonu (2) matching with parentheses: set sm disabled: set nosm (3) Automatic indent: set aiset noai (4) highlighted search set hlsearchset nohlsearch (5) syntax coloring syntax onsyntax off (6) Ignore character case-sensitive set icset noic exercise: 1. Reuse the search and replacement command to delete the blank characters at the beginning of the line in the file; % s/^ [[: space:] // g2. Replace the SEARCH Command with # At the beginning of each line of the file with a blank character. The original blank characters are retained; % s/^ \ s \ +/# &/g3, replace/etc/sysconfig/init in the/tmp/functions file with/var/log; % s #/etc/sysconfig/init #/var/log # g 4. Delete the beginning of # In the/tmp/functions file, and # The Beginning of the line with at least one blank character # % s/^ \ (# \) \ (\ s \ + \)/\ 2/g

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.