VI/Vim shortcut

Source: Internet
Author: User
The cursor control command moves the cursor h or ^ h to move one character J or ^ n to move one row K or ^ P to move one row up l or space to move one character G to the right the last line of the file moves ng to the nth line of the file W to the beginning of the next word w to the beginning of the next word, ignore the movement of punctuation B to the beginning of the previous word, ignore punctuation l move to the last line of the screen M move to the middle line of the screen h move to the first line of the screen e move to the end of the next word, ignore punctuation marks (move to the beginning of a sentence) move to the end of the sentence {move to the beginning of the paragraph} to the beginning of the next paragraph 0 or | move to the first column of the current row n | move to the N column of the current row ^ move to the first row of the current row non-empty character $ move to the last character of the current line + or return to the first character of the next line-Move to the first non-empty character of the previous line add text command insert action a in VI insert text a after the cursor insert text in the current row I insert text before the cursor I insert text before the current Row O Insert new lines under the current row o Insert a new row above the current row: R file to read the file content, and insert it into the current row: NR file to read the file content, after inserting the nth line, escape returns to the command Mode ^ V char ignores the specified meaning of Char during insertion, this is to insert special characters to delete text commands in VI delete operation x Delete characters at the cursor, you can add the number of characters to be deleted before X. NX deletes n characters from the current cursor. x deletes the characters before the cursor, you can add the number of characters to be deleted before X. NX deletes n characters from the current cursor. dw deletes n characters to the beginning of the next word. ndw deletes n words from the current cursor. DG deletes rows., until the end of the file dd Delete the entire row NDD from the current row and then delete the DB Delete the word before the cursor NDB from the current row Delete n words: N, MD deletes n rows D or d $ from Row M to the end of line dcursor_command to the cursor command, for example, DG will delete the previous Character ^ W during insertion, delete the previous word modify VI text the number before each command indicates the number of times this command is repeated command replace operation rchar Replace the current character with Char R text escape Replace the current character with text until the ESC key stext escape uses text to replace the current character s or cctext escape and uses text to replace the entire line cwtext escape. Change the current word to textctext escape and change the remaining content of the current line to textcg escape to the end of the file ccursor_cmd text escape the current position changes to the cursor command position to text in VI search and replace command search and replace operation/text search forward in the file text? Text searches for textn in the file and finds again in the same direction. N searches again in the opposite direction. ftext searches forward in the current row. textftext searches backward in the current row. textttext searches forward in the current row. Text, the cursor is located at the first character of the text, ttext, to search for the text in the current line, and the cursor is located at the first character of the text: Set IC search, Case Insensitive: set noic search is case sensitive: S/oldtext/newtext replace oldtext: m with newtext, NS/oldtext/newtext replace oldtext & amp with newtext in m rows; repeat the final: s command: G/text1/S/text2/text3 to find the row containing text1 and replace text2 with text3: g/text/Command run the command in all rows that contain text: V/text/Command run co in all rows that do not contain text Command in mmand Copy text command in VI copy operation YY put the content of the current row into the temporary buffer nyy put the content of N rows into the temporary buffer P put the text in the temporary buffer after the cursor P put the text in the temporary buffer in front of the cursor dsfsd "(a-Z) nyy copies n rows and places them in the nameable buffer zone named parentheses. If n is omitted, it indicates the current row. "(a-z) NDD deletes n rows and places them in the nameable buffer zone named parentheses, omitting n indicates the current row "(a-z) P puts the content of the nameable buffer named parentheses after the current row" (a-Z) p: Put the content of the nameable buffer with parentheses into the current row. Undo and repeat the command in VI. Undo the Operation U undo the last modification U undo all the modifications of the current row. repeat the last modification and repeat the previous F, F, T, or t search command in the opposite direction; repeat the previous F, F, T, or t SEARCH Command "NP retrieves the last n deletions (the buffer contains a certain number of deletions, usually 9) n repeats the previous/or? Search for command n to repeat the previous/or? Command to save the text and exit VI command to save and/or exit Operation: W save the file but do not exit VI: W File Save the changes in file but do not exit VI: WQ or ZZ or: X save the file and exit VI: Q! Do not save the file. Exit VI: E! Discard all modifications and edit the option in VI from the last time the file is saved. function: Set all print all options: Set nooption disable option: Set nu print row number before each row: set showmode: whether to display the input mode or the replacement mode. Case sensitivity is ignored when set noic is searched: set list displays the tab (^ I) and line tail symbols: set Ts = 8 set tab stops for text input: Set window = N set text window display n rows VI status option function :. = print the row number of the current row: = print the number of lines in the file ^ g display the file name, the current row number, the total number of lines of the file and the percentage of the file location: l use the letter "L" to display many special characters, for example, tabs and line breaks are used to locate paragraphs and place tag options in the text. {insert in the first column. {define a paragraph [[back to the beginning of a paragraph] Move Forward to the beginning of the next paragraph. m (A-Z) use a letter to mark the current position. For example, use MZ to mark Z' (a-z) to move the cursor. To the specified tag, for example, use 'z to move to Z to connect rows in VI option. J. Connect the next row to the end of the current row. The next n rows are connected. The cursor is placed. The screen adjustment option is used. H. move the cursor to the screen. to move the cursor to line n m under the top line of the screen move the cursor to the center of the screen l move the cursor to the bottom line of the screen NL move the cursor to line N on the bottom line of the screen ^ e (CTRL + E) roll one line on the screen ^ y roll one line down the screen ^ U roll up half page ^ D roll down half page ^ B roll up one page ^ F roll down the screen one page ^ L re-paint screen Z-return set the current row to the top line of the screen NZ-return set the nth row under the current row to the top line of the screen Z. set the current row to the center of the screen NZ. set row N on the current row to the center of the screen Z-set the current row to the bottom line NZ-set row N on the current row to the bottom line of the screen role of the shell escape Command Option in VI :! Command :! Ls :!! Run the previous shell command: R! The command reads the input of the command and inserts it, for example, R! Ls will first execute LS and then read the content: W! Command uses the edited file as the standard input of the command and executes the command, for example, W! Grep all: CD Directory change the current working directory to the directory indicated by Directory: Sh will start a sub-shell, use ^ d (CTRL + d) to return VI: So file in Shell Program In file, read and execute the macro and abbreviation in command VI (do not use control keys and symbols, do not use the character K, V, G, Q, V, *, =, and function keys) Options: map key command_seq defines a key to run command_seq. For example, map e EA can always move e to the end of a word to append text: map displays all the defined Macros in the status line: umap key. Macro: AB string1 string2 defines an abbreviation, so that when string1 is inserted, string2 replaces string1. When you want to insert text, type string1 and Press ESC. Then the system inserts string2: AB to display all abbreviations: una string cancels the abbreviation of string in VI to indent the text option. ^ I (CTRL + I) or when the tab is inserted into the text, the width of the movement is defined in advance: set AI enable auto indent: set Sw = N set the moving width to n characters <make n rows move to the left one width n> make n rows move to the right one width, for example, 3> move each row of the next three rows to the right to move the width.
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.