Vim Quick Start

Source: Internet
Author: User

Learning from: Experimental building

VIM has 6 basic modes and 5 derivation modes

Normal Mode:

The default mode after Vim is started, commonly used editor commands such as moving the cursor and deleting text.

In normal mode, there are many ways to enter the insert mode, usually a or I key.

Insert mode:

Most keys in this mode insert text into the text buffer. Return to normal mode by pressing ESC

Visual mode:

Similar to normal mode, but the move command expands the highlighted text area. The highlighted area can be a character, a line, or a piece of text. When a non-moving command is executed, the command is executed to the entire highlighted area.

Select mode:

This mode can use the mouse or cursor keys to highlight the selection of text, but the input of any character, Vim will use this character to replace the selected highlighted text block, and automatically enter the insertion mode.

Command-line mode:

You can enter text that will be interpreted and executed. After the command executes, VIM returns to the previous pattern.

Ex mode:

Similar to command-line mode, you can execute multiple commands at once.

Common mode, insert mode and command line mode are commonly used.

==============================================

Common mode switching:

Press ESC or ctrl+[to return to normal mode

Press I or a in normal mode to enter insert mode

Press: Enter command line mode, enter WQ in command line mode after carriage return: Save and exit Vim

==============================================

To enter the vim edit file:

$ vim file_name

$ vim

To save the document:

Normal Mode input: Enter the command line mode, enter W return or enter: w file_name Save the document to a different file name or other path.

Exit Vim:

Normal Mode input: Enter command line mode, enter: Wq return #保存并退出

Or:

: Q #退出

: wq! #强制保存或退出

And so forth

Save and exit Vim:shift+zz in normal mode

Delete Vim text information in normal mode:

X or Delete #删除游标所在字符

X #删除游标所在前一个字符

DD #删除整行

D #删除至行尾

d^ #删除至行首

DG #删除到文档结尾

D1G #删除至文档首部

2DD #删除2行

Repeat last command: Normal mode "."

Executes the same command as the specified number of times:n<command>

Quick jump for cursors: slightly

Copy and paste:

Use y replication in normal mode: has specific replication details.

Paste with P

Cut: DD

=======================================================

Substitution and revocation of characters (normal mode)

r+ to replace letters #将游标所在字母换位指定字母

R #连续替换 until ESC is pressed

CC #替换整行: Delete the row of the cursor and enter insert mode

CW #替换一个单词

C #替换游标以后至行末

~ #反转游标所在字母大小写

U{n} #撤销n次操作

U #撤销当前行的所有修改

Ctrl+r #redo

Normal Mode:

Num+g #跳转到第num行

<< or >> #快速左右缩进

: Set Shiftwidth=value #设置缩进的大小

/+string #向下查找

? +string #向上查找

After entering the search:

N #继续查找

N #反向继续查找

=======================================================

Multi-file editing:

$vim file1 file2 #创建新文件同时进入编辑

: N #编辑file2文件

: N #编辑file1文件

: E file3 #打开file3

: e# #回到前一个文件

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.