Common use features of the VIM editor

Source: Internet
Author: User
Tags first string

Vim is a well-known, powerful, highly customizable text editor similar to VI, which improves and adds many features on the basis of VI.

Mastering the Simple VIM command can greatly improve the efficiency of our editing document, and in the Linux system terminal input Vimtutor with the VIM editor, will open a copy of the system's own vim editor's instruction.

The following summary is from the text content , Bo Master to extract the summary part, convenient for normal inspection.

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

Special Note: Pressing the <ESC> button will take you back to normal mode or undo a not to enter or partially complete
's command.


Summary of the second lecture

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 the entire row, enter: DD

Many commands that change text consist of an operator and an action.
The deletion command using the delete operator D is in the following format:

D Motion

which
D-delete operator.
Action object for the motion-operator (listed below).

A short list of actions:
W-does not include its first character from the current cursor position until the beginning of the next word.
e-from the current cursor current position until the end of the word, including the last character.
$-from the current cursor current position until the end of the current line.

So the input de is removed from the current cursor position to the end of the word.

Special tips:
For the intrepid seeker, under normal mode, just press the key that represents the corresponding action instead of the operator, and you
You will see the cursor move as the list of objects above represents.


4. To repeat an action, precede it with a number: 2w
5. The format for modifying commands in normal mode is:
operator [NUMBER] Motion
which
Operator-operators, which represent things to do, such as D for deletion
[NUMBER]-numbers that can be appended, representing the number of times the action repeats
Motion-action, which represents the movement of the text on which it is 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 the previous action, enter: U (lowercase u)
To undo the changes you made in one line, enter: U (uppercase U)
To undo the previous Undo command and restore the previous operation results, enter: Ctrl-r

Many commands that change text consist of an operator and an action.
The deletion command using the delete operator D is in the following format:

D Motion

which
D-delete operator.
Action object for the motion-operator (listed below).

A short list of actions:
W-does not include its first character from the current cursor position until the beginning of the next word.
e-from the current cursor current position until the end of the word, including the last character.
$-from the current cursor current position until the end of the current line.

So the input de is removed from the current cursor position to the end of the word.

Special tips:
For the intrepid seeker, under normal mode, just press the key that represents the corresponding action instead of the operator, and you
You will see the cursor move as the list of objects above represents.


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


  Fifth summary

  1.:!command is used to execute an external command. * * ENTER:! The external command can then be executed immediately after entering an external command. * *

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

  2.: w filename  to save the file being edited in the current VIM to a text
     that is named filename.

  3. V motion:w FILENAME to save the selected content in the current edit file in the visual mode to file
     FILENAME.

  4.: r FILENAME Extracts the disk file filename and inserts it into the current file's cursor position
     behind.

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


  Sixth summary

  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 copy text, p pastes the previously copied text.

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

  6. Enter: Set XXX to set XXX options. Some useful options are as follows:
        ' ic ' ignorecase '        Ignore letter case When finding
        ' is ' ' Incsearch '          Find phrase when show partial match
        ' HLS ' Hlsearch '          highlight all matching phrases the
     option name can be either full version or abbreviated version.

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


Summary of the seventh lecture

1. Enter: Help or press the <F1> or <Help> button to open the Assistance window.

2. Input: Help CMD to find assistance with cmd command.

3. Enter Ctrl-w ctrl-w to allow you to jump between windows.

4. Enter: Q to close the Help window

5. You can create a VIMRC startup script file to save your preferred settings.

6. When entering: command, press ctrl-d to view possible completion results.
Press <TAB> to use a complement.


This is the end of the Vim tutorial. This tutorial is just for a brief introduction to the Vim editor, but it is enough to make you
It's easy to use this editor. There is no doubt that Vim has a lot of commands, and this tutorial
The distance is far from complete. So you have to master the words, but also hope to continue to work oh. Next you can read
Vim's user manual, using the command:: Help user-manual

The following book is worth recommending for further reading and learning:
Vim-vi Improved-steve Oualline
Publisher: New Riders
This is the first book to fully explain Vim. It is especially useful for beginners. It contains a large number of instances
and illustrations.
For more information, please visit http://iccf-holland.org/click5.html

The following book is more old and more about Vi than Vim, but it is also recommended:
Learning the Vi Editor-linda Lamb
Publisher: O ' Reilly & Associates Inc.
This is a good book through which you can almost learn anything you want to do with Vi.
The sixth version of the book also contains some information about Vim.

This tutorial was made by Michael C. Pierce from Calorado School of Mines and
Written by Robert K. Ware, many of the ideas are from the Colorado state University
Provided by Charles Smith. The editor's e-mail address is: [Email protected]

This tutorial has been revised by Bram Moolenaar specifically for Vim.

Dubbing PostScript:
===========
Simplified Chinese Course translated version of the dubbing for Liangchante <[email Protected]>
Another contact address: [email protected].

The traditional Chinese course is a simplified Chinese translation version using the Debian gnu/linux Chinese project Small
The group of Mr. Yu Guanghui wrote the Chinese character transcoding AutoConvert converted and turned
Change the results to make some changes to the details.


Common use features 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.