Use of Vim under Linux

Source: Internet
Author: User

VI and VIM
The VI Editor is the standard editor for all UNIX and Linux systems, and he is the equivalent of a notepad in the Windows system, which is no less powerful than any of the latest text editors. He is a tool we cannot use without a Linux system. As with any version of UNIX and Linux systems, the VI editor is exactly the same, and after learning it, you will be unimpeded in the world of Linux.
Vim has the ability of program editing, can distinguish the correctness of grammar by font color, and facilitates program design;
Because the program is simple, the editing speed is quite fast.
Vim can be used as an upgraded version of VI, and he can display some special information in a variety of colors.
Vim will automatically execute the syntax judgment of the program according to the file extension or the beginning information in the file, and then display the program code and general information in color.
Vim adds a lot of additional features, such as support for regular expression search, multi-file editing, block copying, and so on. This is a great feature for the modification of some of the configuration files on Linux.


Why to learn VI
All UNIX like systems will have a VI text editor built in, and other text editors will not necessarily exist;
Some of the software's editing interface will actively call VI (such as crontab, Visudo, Edquota and other commands);

Use of VI
Basically VI can be divided into three states, namely the general mode, the editing mode and the command line mode, the function of each mode is distinguished as follows:

General mode:
Open a file with VI directly into the general mode (this is the default mode). In this mode, you can use the left and right buttons to move the cursor, you can use the deletion of characters or delete the entire line to process the contents of the file, you can also use copy, paste to process your file data.

Edit mode:
In general mode can be deleted, copy, paste and other operations, but cannot edit the contents of the file, only when you press "I, I, O, O, A, a, R, R" and so on any one letter will enter the editing mode. The word "Insert or REPLACE" appears at the bottom left of the screen, so you can edit it. If you want to go back to normal mode, you must press ESC to exit edit mode.

Command-line mode:
Enter ":/? Any of the three, you can move the cursor to the bottom row. In this mode, you can provide search, read, save, replace characters, leave VI, display line number and other actions are done in this mode!

Description of buttons available in general mode
Move cursor
"H, J, K, L", respectively, control the cursor left, bottom, up and right one grid
Press "ctrl+b" screen to move one page to "back"
Press "ctrl+f" screen to move one page toward "front"

"n<space>" cursor moves n characters to the right
"Home" moves to the front of the line prompt: 0 digits, but not with numbers on the numeric keypad

"End" moves to the last face of this line prompt: $, I'm not testing it.
"W" cursor jumps to the beginning of the next word
"E" cursor jumps to the end of the next word

The "H" cursor moves to the first character of the line at the top of the screen
The "M" cursor moves to the first character of the line in the middle of the screen
The "L" cursor moves to the first character of the line at the bottom of the screen

"G" moves to the last line of this file
"NG" moves to the nth row of this file (mates: Set Nu)
"GG" moves to the first line of this file, equivalent to 1G
"n<enter>" cursor moves down n rows

Find and replace
"/word" looks down at the cursor for a string called word
"word" looks up a string with a name called Word to the cursor
"N" represents the action of repeating the previous lookup
"N" is exactly the opposite of N and a find action for "reverse" before the line

Use of Vim under Linux

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.