Configure Vim in Ubuntu and display different colors in different syntaxes

Source: Internet
Author: User

Configure Vim in Ubuntu and display different colors in different syntaxes

Step 1. install the vim command: sudo apt-get install vim

Step 2: Change the vim configuration file etc/vim command to: (1) cd/etc/vim (2) sudo gedit vimrc

(1) enter the/etc/vim directory. (2) Open the vimrc File

Step 3: Insert the following content in a line anywhere in vimrc

Syntax on
Set tabstop = 4
Set shiftwidth = 4
Set autoindent
Set cindent
Set cinoptions = {s, t0, N-2, p2s, (03 s, =. 5 s,> 1 s, = 1 s,: 1 s
Set nu
Set softtabstop = 4

Step 4: Save the file and it will end. Then open the. c file with vim, And the highlighted file and different syntax colors will be displayed.

/* Explain the meaning of the content set above */
Syntax on // set syntax highlighting
Set tabstop = 4 // set the tab width to 4
Set softtabstop = 4 // set the soft tab width to 4
Set shiftwidth = 4 // set the number of indented spaces to 4
Set autoindent // set Automatic indent
Set cindent // set the automatic indent mode in C/C ++ Language
Set nu // display the line number of the text on the left

Configuration file:

After successful configuration and preview:

Recommended reading:

Vim Learning Guide

Quick learn Vi Editor

Powerful Vim Editor

Build a Vim Development Environment on CentOS 6.2

Vim 7.4a released, a new and faster Regular Expression Engine

Install the highlighted Vim editing tool in CentOS 5.4

Vim tips: C language settings

Set the Vim row number in Ubuntu

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.