[Embedded Training note]-----Vim Editor Usage profile

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 the following command to discard all changes:

<ESC>: q! < Enter >

Or, enter the following command to save all changes:

<ESC>: Wq < Enter >

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

5. In normal mode, to start inserting text at the cursor position, press:

I input necessary text <ESC>

Special Note: Pressing the <ESC> button will take you back to normal mode or cancel an unexpected or partially completed
's command.

Well, that's the end of the first. Let's move on to the second part of the story.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summary of the second lecture


1. To delete from the current cursor to the end of the word/words, 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

4. The format of a command in normal mode is:

[NUMBER] Command object or Command[number] Object
The meaning is:
Number-Represents the amount of times the command was executed
Command-Represents the thing to do, such as D for deletion
Object-Represents the objects to be manipulated, such as w for word/word, $ for the end of the line, and so on.
$ (to the end of line), etc.

5. 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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summary of the third lecture


1. To reset the deleted text content, enter the lowercase letter p. 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.

3. The Change Class command allows you to change the specified object from the current cursor position to the end of the object.
For example, the input CW 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:

[NUMBER] CObject or C [number] Object

Let's continue with the next lesson.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summary of the four words


1. Ctrl-g is used to display the current cursor location and file status information. Shift-g is used to jump the cursor
Go to the last line of the file. First typing a line number and pressing SHIFT-G moves the cursor to the line
Number represents the line.

2. Enter/Then followed by a string is the string that is searched backwards in the currently edited document.
Enter a question mark? followed by a string is the word that is searched forward in the currently edited document
Character string. Pressing the N key after completing a lookup is the last command that can be checked in the same direction
Find the next string, or press Shift-n to look in the opposite direction for the string where it is located.

3. If the current position of the cursor is parentheses (,), [,], {,}, press% to move the cursor to the paired
The 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 you make a full-text substitution, ask the user to confirm that each replacement needs to add C option, enter:%S/OLD/NEW/GC


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Summary of the five words


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

Take a look at some practical examples:
:!dir-Used to display the contents of the current directory.
:!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.: #, #w FILENAME to save the contents of the current Edit file # line to # line 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.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A summary of the six words


1. Enter lowercase o to open a new line below the cursor and place the cursor at the beginning of the new opening, entering
Insert mode.
Enter an uppercase O to open a new line above the cursor and place the cursor at the beginning of the new opening, entering
Insert mode.

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. Enter the uppercase R to enter the replacement mode until you press <ESC> to exit the replacement mode and enter the normal
Mode.

4. Enter: Set XXX to set XXX options.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Seventh Talk: Online Help commands

* * Use the online Help system * *

Vim has a meticulous and comprehensive online Help system. To start the Help system, select the following three types of
One of the methods:
-Press the <HELP> key (if there is one on the keyboard)
-Press the <F1> key (if there is one on the keyboard)
-Input: Help < return >

Enter: Q < Enter > to close the Help window.

Provide a correct parameter to the ": Help" command, you can find assistance on this topic. Please experiment to
The next parameter (don't forget to press ENTER!). :):

: Help W < Enter >
: Help C_<t < Enter >
: Help Insert-index < Enter >
: Help User-manual < Enter >


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eighth: Create a startup script

* * VIM enabled function * *

Vim has much more functional features than VI, but most features are not activated by default. In order to start more
function, you have to create a VIMRC file.

1. Start editing the VIMRC file, depending on the operating system you are using:

: Edit ~/.VIMRC This is the command used by the UNIX system
: Edit $VIM/_VIMRC This is the command used by the Windows system

2. Then import the VIMRC sample file:

: Read $VIMRUNTIME/vimrc_example.vim

3. Save the file with the following command:

: Write

The next time you start Vim, the editor will have a syntax highlighting feature. You can continue to bring your favorite
Add the other feature settings to this VIMRC file.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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 learn to use this editor. There is no doubt that Vim has a lot of commands, and this tutorial
It's still a long way from here. So you have to master the words, but also hope to continue to work oh. Next you can read
VIM Handbook, the commands used are:
: Help User-manual

For further reference and study, the following book is worth recommending:

Vim-vi Improved-author: Steve Oualline
Publisher: New Riders

This is the first book to fully explain vim. Especially useful for beginners. It also contains a large number of instances
and illustrations. For more information, please visit http://iccf-holland.org/click5.html

The following book is older and the content is mainly VI rather than vim, but it is also recommended:

Learning the Vi Editor-Author: Linda Lamb
Publisher: O ' Reilly & Associates Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Embedded Training Note-----Introduction to VIM editor usage

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.