A simple summary of the VIM editor

Source: Internet
Author: User
Tags first string

Summary of the first lecture
1. The cursor can be moved in the screen text using either the arrow keys or the HJKL letter key.
H (Shift left) J (downlink) K (upstream) L (shift right)

2. To enter the Vim editor (from the command line prompt), enter: Vim file name < Enter >

3. To exit the Vim editor, please enter <ESC>: q! < Enter > Discard all changes.
or enter <ESC>: Wq < Enter > Save changes.

4. In normal mode, delete the character of the cursor position, press: X

5. To insert or add text, enter:

I input to insert text <ESC> insert text before cursor
A input to add text <ESC> add text after one line

  Second Summary
  1. To delete from the current cursor to the next word, enter: DW
  2. To delete from the current cursor to the end of the current line, enter: d$
  3. To delete an entire row, enter: DD

  4. To repeat an action, precede it with a number: 2w
  5. The format for modifying commands in normal mode is:
                operator   [number]   Motion
      Where:
       operator-operator, which represents what to do, such as D for delete
        [number]-numbers that can be appended, representing the number of repetitions of the action
       motion  -action, Represents a move on the text that is being manipulated, such as w for word (word),
                   $ represents the end of the line and so on.

  6. To move the cursor to the beginning of the line, press the number 0 key: 0

  7. To undo a previous action, enter: U (lowercase u)
     to undo changes made in one row, Please enter: U (uppercase U)
     to undo the previous Undo command and restore the previous operation result, enter: Ctrl-r

Summary of the third lecture
1. To reset the deleted text content, press the lowercase p key. This action can remove a deleted
Text content is placed after the cursor. If the last time you delete an entire line, the row will be
The next line in the row where the current cursor is located.

2. To replace the character at the cursor location, enter the lowercase r and the new word that replaces the original position character
Characters.

Summary of the four words


1. Ctrl-g is used to display the current cursor location and file status information.
G is used to jump the cursor to the last line of the file.
Type a line number first and then enter uppercase G to move the cursor to the line represented by the line number.
GG is used to jump the cursor to the first line of the file.

2. Enter/Then immediately follow a string to find the string in the currently edited document.
Input? followed by a string is the reverse lookup of the string in the currently edited document.
Pressing the N key after a search is done repeats the last command and can be checked in the same direction
Find the next matching string, or in the opposite direction of uppercase N to find the next matching string.
Ctrl-o takes you back to an older location, and Ctrl-i takes you to a newer location.

3. If the current position of the cursor is parentheses (,), [,], {,}, pressing% will move the cursor to the pair of parentheses.

4. Replace the first string in a line with old as the new string, enter: S/old/new
Replace all of the strings in a row with old as the new string, please enter: s/old/new/g
Replace all the strings in the two lines with old for the new string, enter: #, #s/old/new/g
Replace all the strings in the file with old for the new string, please enter:%s/old/new/g
When a full-text substitution is made, ask the user to confirm that each replacement needs to be added C flag:%S/OLD/NEW/GC



3. The Change Class command allows you to change the text from the current cursor position to the middle of the position indicated by the action.
For example, the input CE can replace the current cursor to the end of the word, input C $ can be replaced when
The contents of the front cursor to the end of the line.

4. The format of the Change Class command is:

c [NUMBER] Motion
Summary of the five words


1.:!command is used to execute an external command.

Take a look at some practical examples:
(MS-DOS) (Unix)
:!dir:!ls-Used to display the contents of the current directory.
:!del filename:!rm filename-Used to delete a file named filename.

2.: w FILENAME saves the file being edited in the current VIM to a text named filename
Components.

3. V Motion:w FILENAME to save the selected contents of the current edit file in the visual mode to a file
In FILENAME.

4.: r filename Extracts the disk file filename and inserts it at the cursor position of the current file
Behind.

5.: R!dir can read the output of the dir command and place it behind the cursor position of the current file.


A summary of the six words

1. Enter lowercase o to open a new line below the cursor and into insert mode.
Enter an uppercase O to open a new line above the cursor.

2. Enter lowercase A To insert text after the cursor position.
Enter uppercase A to insert text after the end of the line in which the cursor is located.

3. The e command allows you to move the cursor to the end of the word.

4. Operator y copies the text, p pastes the previously copied text.

5. Enter the uppercase R to enter the replacement mode until you press <ESC> to return to normal mode.

6. Enter: Set XXX to set XXX options. Some of the useful options are:
' IC ' ignorecase ' ignores letter case when searching
' Is ' ' incsearch ' shows partial match when finding a phrase
' HLs ' hlsearch ' highlights all the matching phrases
The option name can be either a full version or an abbreviated version.

7. Add no to the option to close the option:: Set Noic


A simple summary 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.