Vim common shortcut key Configuration

Source: Internet
Author: User

Vim common shortcut key Configuration

In Linux, when you use VI to write C/C ++ programs. h. CPP. CC and other files sometimes have many similar operations. If we need to complete the input for each similar operation, it will reduce the efficiency of writing programs. Simple configuration, that is, you can use common shortcut keys, which will be the prerequisite for Happy program writing.

Now, the simple configuration records when I write a program using Linux VI are as follows:


If you configure Vi, you need to use a vimrc file. Under the/etc directory, there is a vimrc file that can be configured. In this case, all users logging on to Linux can share these configurations. However, we may not be able to obtain the permission to edit the/etc/vimrc file, so we still need to configure the current user's vimrc.


When we use an account to log on to the Linux system, that is, out of the current user's home directory, each user has its own Vim configuration file, namely. vimrc. We can use

Cd ~

Enter the current user's home directory, and then use

Ll-A. vimrc

Command to check whether this file exists. If it does not exist, we can create this file.

Vi. vimrc

Then we can perform the following settings:

Line 3 enables syntax highlighting.

Row 2nd is the line number that opens vi

Row 3 sets the tab in VI, that is, the size of the tab key.

6th ~ The eight lines are our customized shortcut key settings for C/C ++ programming.

When writing a program, input

. I

Then press enter to display # include <iostream>

This reduces the burden on writing code.

In addition, paste a piece of configuration found on the Internet

Vim Configuration
-Right two (read: 152)
1. Enter sudo Vim/etc/vimrc in the terminal and press Enter.
2. Enter the following content:
"Display row number
: Set nu

"Tab width
: Set Ts = 4

"Auto indent
: Set Sw = 4

"C/C ++ Style Auto indent
: Set CIN

"Enable Automatic indentation for common file types
: Set AI

"The following are commonly used custom shortcut keys
"Usage is: for example, if you enter. I and press ENTER or space key, the output will be # include
AB. I # include
AB # I # include
AB. L # include
AB. s # include
AB. m int main (INT argc, char * argv [])
AB. P printf ("/N ");
AB. Q printf ("Please input.../N ");
AB. r return 0;

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.