Common vim commands, differences between vim and vi, and common vim commands vi

Source: Internet
Author: User

Common vim commands, differences between vim and vi, and common vim commands vi

Differences between vim and vi

They are all multi-mode editors. The difference is that vim is an upgraded version of vi. It is not only compatible with all instructions of vi, but also has some new features in it.

Vim has the following advantages:

1. Multilevel Revocation

We know that in vi, you can only undo the last command by pressing u, but you can undo it without limit in vim.

2. ease of use

Vi can only run in unix, while vim can not only run on unix, windows, mac, and other multi-operating platforms.

3. Highlight the syntax

Vim can use different colors to highlight your code.

4. Visualized operations

That is to say, vim can run not only on the terminal, but also on x window, mac OS, and windows.

5. fully compatible with vi

In some cases, you can use vim as vi.

Vi and vim are both Linux editors. The difference is that vim is relatively advanced and can be regarded as an upgraded version of vi. Vi is used for text editing, but vim is more suitable for coding.

Vi has three modes: insert mode, command mode, and low-line mode.

Insert mode: You can enter characters in this mode. Press ESC to return to the command mode.

Command mode: you can move the cursor or delete characters.

Low-line mode: You can save files, exit vi, set vi, search, and other functions (low-line mode can also be seen as in command mode ).

Remember that every time you run the vim editor, the default value is"Command mode", You must first enter"Input mode"Before writing the document, and each edit is complete, you must first return to"Command mode"And then enter"Last Row Mode"Save or exit the text.

Here we have summarized the most commonly used shortcut key commands for you. You should remember them as much as possible.

Common shortcut keys in the command mode of the vim Editor

Dd // Delete (CUT) the entire row of the cursor 5dd // Delete (CUT) start 5 rows from the cursor yy // copy the entire row 5yy // copy 5 rows starting from the cursor p // Delete (dd) or copy (yy) pasted data to the cursor/string // search this string from top to bottom in the text? String // search the string n from bottom to bottom in the text // display the Next string N located by the SEARCH Command // display the previous string u located by the SEARCH Command // undo operation

Common commands in the last line mode of the vim Editor

: W // save: q // Exit: q! // Force exit (discard text modification): wq! // Force save and exit: set nu // display line number: set nonu // do not display line number: Command // execute this command: integer // jump to this line

Notes

1. In command mode and last line mode, all shortcut key parameters are case sensitive.

2. In the last line mode, there is a ":" Before all shortcut key parameters.

View the document content: cat file name

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.