Vim Quick Start

Source: Internet
Author: User

Vim mode Introduction

Introduction to Vim's three modes

Vim has three working modes: Command mode, insert mode, and baseline mode.

Command mode: Enter the vim command and start Vim to enter the command mode by default. At this time, all keys are function keys.

Insert mode: In command mode, press "I" to enter the insert mode, and then edit the text like in notepad.

Baseline mode: Enter ":" In command mode to enter baseline mode, which can be used to save files, exit vim, and set the environment to execute compilation commands.

Switching between the three modes

Start Vim to Enter command mode

In insert mode or baseline mode, you only need to press the "ESC" to return to the command mode.

In command mode, press the "I" (insert) or "A" (append) Key to enter the insert mode.

In command mode, press ":" to enter the baseline mode.

Enter "WQ" in baseline mode and press enter to save and release vim.

Enter Vim

Use the vim command to enter the vim Interface

Vimis the command to open vimtest.txt is the name of the file you open or create.

TC @ box :~ $ Vim test.txt

You can use Vim to open the vim editor without opening any files.

TC @ box :~ $ Vim

Enter "e test.txt" in the baseline mode to open the test.txt file.

Move cursor

Move the cursor of the Vim Editor

After entering vim, press the "I" key to enter the insert mode. In this mode, you can enter text information.

Enter the following three lines:

12345678

Abcdefghijk

Testtesttest

Press ESC to enter the command mode. In this mode, you can use the direction key or the hjkl key to move the cursor.

H: left;
L (lower case l): Right
J: Bottom
K: Upper

W: Move to the next word

B: Move to the previous word.

Please try to use the cursor key in command line mode to move the cursor in text

After selecting a specific text location, you can start editing in edit mode.

Enter edit mode

Use commands to enter the editing mode

Enter the following letters in command mode to edit the text.

I edit at the current cursor

A insert and edit behind the cursor

O Insert a new row after the current row

O Insert a new row before the current row

CW replaces the character from the cursor position to the end of a word

Try different methods to switch from command mode to edit mode. Do not forget that the ESC key can be returned from edit mode to command mode.

Save document

Save the document in baseline Mode

Enter ":" In command mode to enter baseline mode. Enter W and press enter to save the document.

Exit Vim

Exit Vim in baseline Mode

Enter ":" In command mode to enter the baseline mode, enter WQ and press Enter. You can also save and exit the editing by using other Exit commands. The ":" command before the command indicates that the baseline mode is in.

: Q! Force exit, not save

: Q exit

: WQ! Force save and exit

: Saveas <path/to/File> Save As <path/to/File>

: X or: WQ save and exit

Exit Vim in command mode

In command mode, enter "ZZ" to save and exit vim.

Delete text

Delete Vim text information in command mode

Enter the command mode and use the following command to quickly delete the text:

X Delete the character of the cursor

X Delete the character before the cursor

"Del" button to delete the current character

Dd deletes the entire row

DW deletes a word (not applicable to Chinese)

Delete DG to the end of the document

Delete d1g to Document Header

D $ Delete to the end of the row

 

Vim Quick Start

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.