Vim Common commands

Source: Internet
Author: User
Tags save file

Some of the commands commonly used by the VIM editor under Linux (what to add)

Command mode:

: Set Nu #显示行号

: Syntax on #语法高亮

: Set tabstop=4 #tab back four grid

VI has three modes: insert mode, command mode, low line mode

Insert mode: You can enter characters in this mode, press ESC to return to command mode

Command mode: You can move the cursor, delete characters, etc.

Low-line mode: can save files, exit VI, set VI, Find and other functions (low-line mode can also be seen as a command mode)

Open file, save, close file (used in VI command mode)

VI filename//open filename File

: w//Save File

: Q//Exit editor, if the file has been modified, use the following command

: q! Exits the editor without saving

: Wq//Exit editor, and save

Insert text or lines (used in VI command mode, enter insert mode after executing the command below, press ESC to exit insert mode)

A//Add text to the right of the current cursor position

I//Add text to the left of the current cursor position

A//Add text at the end of the current line

I//Add text at the beginning of the current line (the beginning of a non-empty character)

O//Create a new row above the current line

O//Create a new row below the current line

R//replace (overwrite) the current cursor position and several subsequent text

J//Merge cursor row and next line of behavior (still in command mode)

Delete, restore characters or lines (used in VI command mode)

X//Delete current character

NX//delete n characters starting from the cursor

DD//Delete when moving forward

NDD//Down Delete the current row, including n rows

U//Undo Previous action

U//Undo all operations on the current line

Copy, paste (used in the VI command mode)

YY//Copy the current line to the buffer

Nyy//Copy the current row down n rows to the buffer

YW//Copy characters from the beginning of the cursor to the ending

NYW//Copy n words starting from the cursor

y^//Copy contents from cursor to beginning of line

y$//copy content from cursor to end of line

P (lowercase)//paste the contents of the Clipboard after the cursor

P (uppercase)//paste the contents of the Clipboard in front of the cursor

Set line number (used in VI command mode)

: Set nu//Display line number

: Set Nonu//Suppress line numbers

Here is a keyboard diagram

Vim Common commands

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.