The Linux vi/vim command

Source: Internet
Author: User

The VI command is an essential editor tool in Linux. So what is the difference between VI and VIM, can be simply understood as VIM is the upgrade version of VI. When editing a text, vi does not display a color, and vim displays the color. Display colors are easier for users to edit, and other features make no difference. So under Linux, the use of VI or VIM depends entirely on your personal interests.

If this command is not on the CentOS system you just installed, please install it

Yum Install-y vim-enhanced

Three modes of VIM: General mode, edit mode, command mode.

    1. General mode: When you vim filename to edit a file, entering the file is the normal mode. In this mode, you can do the following actions: Move the cursor up or down, delete a character, delete a row, copy, paste one line, or multiple lines.
    2. Edit mode: In general mode, it is not possible to modify a character, only to edit mode. From normal mode into edit mode, you can just press a key (I, I, A, A, O, O, R, R). When you enter edit mode, the words "insert or replace" appear on the bottom line of the screen. To return to normal mode from edit mode, simply click the ESC key at the top left of the keyboard.
    3. Command mode: In normal mode, enter ":" or "/" to enter command mode. In this mode, you can search for a character or a string, or you can save, replace, exit, display line numbers, and so on.

Let's write a simple HelloWorld program.

Enter VIM Hello.java Direct enter into general mode. Then press the "I" letter into the edit mode, in the lower left corner of the window will show "–-Insert--" This means entering the insert mode, you can edit the document.

If you have finished editing and want to save, you need to first click the "ESC" key in the upper left corner of the keyboard, "– Insert –" disappears, and then enter ": Wq" will save the text just now.

At this point, take a look at the contents of the Hello.java document:

In fact, "vim" for the full keyboard operation of the editor, so in all modes have a lot of function keys.

The Linux vi/vim command

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.