Common vim commands in linux

Source: Internet
Author: User

Common vim commands in linux★Command mode: www.2cto.com move the cursor h or move the cursor to the left direction key (Direction) → move the cursor to the left a character j or backward (direction) → move the cursor down to a character k or forward (forward) → move the cursor up to a character l or forward to the right (→) → move the cursor to the right with a character [Ctrl] + [f] → move one page down the screen, it is equivalent to [Page Down] pressing [Ctrl] + [B] → moving a Page Up, equivalent to [Page Up] Pressing n <space> → n to indicate "number 』. Press the number and then press the blank cursor. The cursor will move the n characters in the row to the right. 0 → the number is "0 』: move to the front character of this line $ → move to the last character of this line G → move to the last line of this file nG → n is a number. The Nth row to be moved to the file (can be used with: set nu) gg → the first row to be moved to the file, equivalent to 1G n <Enter> → n is a number. Move the cursor down n rows of www.2cto.com to search for and replace/word → search for a string named word under the cursor. To search for the eric4ever string, enter/eric4ever? Word → search for a string named word over the cursor → "repeat the previous search action" → opposite to n, perform the previous search action for "reverse: n1, n2s/word1/word2/g → n1 and n2 are numbers. Search for the word1 string between line n1 and line n2 and replace it with word2. For example, if you search for eric4ever between lines 1 and 9 and replace it with ERIC4EVER: ": s/eric4ever/ERIC4EVER/g": 1, $ s/word1/word2/g → search for the word1 string from the first row to the last row, and replace the string with word2: 1, $ s/word1/word2/gc → search for the word1 string from the first row to the last row, and replace the character window with word2, whether to delete, copy, and paste x in the displayed dialog box before replacement. X → in a row, x is a forward slash (equivalent to a [del] button ), X is the forward trim except a character (equivalent to a [backspace] button) dd → trim the entire column ndd where the cursor is located → n is a number. Remove the cursor from the next n columns of yy → copy the row of nyy → n as a number. Copy the next n columns of the cursor p, P → p to paste the copied content on the next line of the cursor, P is pasted on the top line of the cursor u → restore the previous action [Ctrl] + r → redo the previous action. → decimal point, meaning to repeat the previous action★Edit mode I, I → insert: insert the input text at the position of the current cursor. The existing text will be backward. Where, I is "insert from current cursor 』, I is "insert the first non-blank character in the current row" a, A → a is "insert from the next character in the current cursor 』, A is "insert from the last character of the row where the cursor is located" o, O → o is "Insert A new row at the next line where the current cursor is located 』, O is "Insert a new row into the previous row where the current cursor is located" r, R → r is "Replace the character where the cursor is located 』, R is the text that replaces the cursor until you Press ESC. Esc → exit the editing mode and return to normal mode.★Last line command mode: w → write the edited file to the hard disk: q → exit vi: wq → save and exit, if it is: wq! It is forcibly saved as exit: set nu → display row number: set nonu → cancel display row number

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.