Third week vim introductory learning 1

Source: Internet
Author: User

I. Introduction of VIM Mode

1. Concept: The following introductory content from the Wikipedia vim

There are many modes of vim from VI, this unique design is easy to confuse the beginner. Almost all editors have two modes of inserting and executing commands, and most editors use a different approach to vim: the command directory (mouse or keyboard driver), the combination of keys (usually with the control key (CTRL) and the ALT key (ALT)) or the mouse input. Vim and VI, just as the keyboard to switch among these modes. This allows vim to operate without a menu or mouse, and to minimize the operation of key combinations. It can greatly enhance the speed and efficiency of the text entry clerk or programmer.

VIM has 6 basic modes and 5 derivation modes, and here we simply introduce the next 6 basic modes:

    • Normal mode
    • Insertion modes (insert mode)
    • Visual modes (visual mode)
    • Selection mode (select modes)
    • Command line mode
    • Ex modes (ex mode)
2. Switching of three common modes

Vim starts into normal mode, in insert mode or command line mode, just press Esc or Ctrl+[ (this is no use in the VIM course environment) to enter normal mode. In normal mode i , press (insert) or a (attach) keys to enter the insert mode, in normal mode press : enter command line mode. In the command line mode, enter the wq carriage return and save and exit Vim.

3. Enter the VIM1. Use the VIM command to enter the Vim interface

Vim is appended with the file name that you want to open, or that does not exist (then as a new file). Open the Xfce terminal and enter the following command

$ vim practice_1.txt

Vim editor can also be opened using Vim directly, but no files will be opened.

$ vim

Enter the command line mode and the :e 文件路径 same file can be opened.

2. Cursor movement

After entering Vim, press the i key to enter insert mode. In this mode you can enter text information below, please enter the following three lines of information:

12345678abcdefghijkshiyanlou.com

Press Esc Enter normal mode, use the arrow keys in this mode or,,, the h j k l Key can move the cursor.

Key Description
h Left
l Right (lowercase L)
j Under
k On
w Move to the next word
b Move to the previous word

Try using the arrow keys to move the cursor over these letters in normal mode shiyanlou .

4. Enter Insert mode 1. Enter insert mode

Use the following key in normal mode to enter insert mode, and to start typing from the corresponding position

Command Description
i Edit at current cursor
I Insert at beginning of line
A Inserting at the end of a row
a Insert an edit after the cursor
o Insert a new row after the current row
O Insert a new row before the current line
cw Replace the character from the position of the cursor to the end of a word

Try different ways to get into the insert mode from normal mode, add in front of the last line Shiyanlou www. , Notice that each time you go back to normal mode to switch to insert mode in different ways

V. Save a Document 1. Save the document in command line mode

Enter the : command line mode from normal mode, enter w a carriage return, and save the document. Enter to save the :w 文件名 document as a different file name or save it to another path

Vi. exit vim1. Exit vim in command line mode

Enter : command line mode from normal mode, enter wq return, save and exit edit

Here are a few other ways to exit:

Command Description
:q! Force quit, do not save
:q Exit
:wq! Force Save and exit
:w <文件路径> Save As
:saveas 文件路径 Save As
:x Save and exit
:wq Save and exit
2. Exiting vim in normal mode

Normal mode input Shift+zz can be saved out of vim

Vii. deletion of text 1. Delete vim text information in normal mode

Go to normal mode and use the following commands to quickly delete text:

Command Description
x Delete the character that the cursor contains
X Delete the previous character of a cursor
Delete Withx
dd Delete entire row
dw Delete a word (not in Chinese)
d$OrD Delete to end of line
d^ Delete to beginning of line
dG Delete to end of document
d1G Delete to document header

In addition, you can add a number to the command before it, indicating that multiple rows are deleted at once, such as:

2ddRepresents delete 2 at a time.

Experimental experience: Learning Vim mode, VIM can be regarded as the advanced version of VI, VIM commands a lot of, but hard to remember quickly and will forget, so the most effective way is: constantly practice.

Third week vim introductory learning 1

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.