Vim plug-in C.vim (for C + +) __c++

Source: Internet
Author: User
Tags format definition

C.vim is a vim for the development of C + + Plug-ins, official website, Links: Vim basic Plug-in installation step 1. Download installation package (cvim.zip), download directly from the official web, I download here is the current version 6.1
2. Install the Plugin

$ mkdir ~/.vim
$ cd ~/.vim
$ unzip/usr/src/cvim.zip

3. Enable Plug-in

$ vim ~/.vimrc
filetype plugin on

C.vim Use

1. After the installation is complete, when a new *.c/*.cpp/*.c++ file is created, some descriptive characters are added automatically.

* * ===================================================================================== * *       Filename :  test.c
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  01/27/2015 04:17:54 PM
 *       Revision:  None
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (),
 *   Organization:
 *
 * ===================================================== ================================
 */
If you want to modify these default characters, you can directly modify the definition of a macro in the file (~/.vim/c-support/templates/templates).
Setmacro (' AUTHOR ',      ' YOUR NAME ')
setmacro (' authorref ', '   )
setmacro (
' company ', ') Setmacro (' COPYRIGHT ', ') setmacro (' EMAIL ', ')
setmacro (' LICENSE ', ')
setmacro (' Organization ', ' "

2. C.vim shortcut keys, such as to create a new code block, you can in three modes (insert mode, general mode, fast mode), directly enter the \SB character. The last Picture: C.vim Common shortcut keys

3. Modify the default template settings, useful reference documents under this path (~/.vim/doc), place the template path (~/.vim/c-support/templates), for example, I want to modify the default main function format

Default main function format:

    int
Main (int argc, char *argv[])
{return
    exit_success;
}

In the default main function format, the return value type is placed on a single line and preceded by a TAB key that finds the template format file (~/.vim/c-support/templates/c.idioms.template) for the main function in the template file. Find the format definition for the main function and put the return value type and main function arguments in one line

Template inside the main function format definition:

= = Idioms.main = = Map:im, shortcut:m  = =
#include    <stdlib.h>/
 * = =  = = FUNCTION = = ===================================================================
 *         Name:  main
 *  Description:
 * =====================================================================================
 * /
int
main (int argc, char *argv[])
{<cursor>
<SPLIT> return exit_success;
}               /*----------end of  function main----------/*  
After the modification, the main function (\im) is displayed directly:

int main (int argc, char *argv[])
{return
    exit_success;
}


Figure: C.vim commonly used shortcut keys

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.