Initial VIM Basics

Source: Internet
Author: User
Tags switches

Vim Text Editor Preliminary

I. Relationship with VI Editor

It can be said that the Vim editor is an upgraded version of the VI editor, which retains all of the VI Editor's things, and adds its own new features.

For example: support cross-platform, support syntax highlighting, support multi-level revocation and so on.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Second, the VIM editor operation mode

The VIM editor has three modes of operation:

(1) Command mode

(2) Input mode

(3) Bottom line mode (tail line, last line)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Third, some operations

Vim file name

Meaning: If the file exists, it will be opened, otherwise it will be created.

For illustrative purposes, let's say we have a file called "abc",

VIM + ABC

Meaning: Quickly position the cursor to the last line of the file ABC

VIM +5 ABC

Meaning: Quickly position the cursor to line 5th of the file ABC. Note that if we locate a line number that exceeds the total number of rows in ABC, we will navigate to

Last line.

Vim/hello ABC

Meaning: Searches the file ABC for lines that contain "hello" and positions the cursor to the first line that contains the hello.

Vim AA bb cc

Meaning: Create (or Open) three files at the same time, named "AA", "BB", "CC", respectively

Take command vim AA bb cc, We have opened these three files, then how to switch among these three files? Use the bottom row mode, such as the following command:

: N switches to the next file

: N switches to previous file

:p Rev is also the meaning of switching to the previous file

: LS lists all files that are currently open

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Iv. continue to introduce some of the commands

In the bottom-line mode and command mode, the available instructions are too many. Here is a list of some common ones.

Bottom-line mode common directives:

: W is the command to save the changes, note that there is no exit

: Q Exits the current VIM editor open file

:! Mandatory execution

: LS lists all open files in the current VIM editor

: n switches to the latter file

: N switches to previous file

:p Rev Switch to previous file

: 15 position the cursor to line 15th

/xxx searches backwards for xxx from the cursor position and positions the cursor where it was first found

? XXX search forward from the cursor position xxx, and position the cursor at the first location to find it

Common directives in command mode

H Cursor Shift Left

J Cursor Move Down

K Move Cursor up

L MOVE the cursor right

Ctrl+f PAGE Down

Ctrl+b PAGE Up

Ctr+d down Half page

Ctrl+u up half a page

DD deletes the cursor in the row

o Insert a row below the line where the cursor is located and switch to input mode

YY the copy cursor is in the row

P (lowercase) paste below the line where the cursor is located

P (uppercase) is pasted above the line where the cursor is located

There are too many instructions, here is a vim instruction diagram on the keyboard, you can see learning:

Initial VIM Basics

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.