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