sponsor Vim development Vim logo Vim Book Ad

headerGatesAdd.vim : automatic inser C/C++ header gates

 script karma  Rating 55/16, Downloaded by 1400  Comments, bugs, improvements  Vim wiki

created by
帅 得不敢出门
 
script type
utility
 
description
C/C++ header files should be guarded against multiple inclusions using preprocessor directives, e.g.:
let g:HeaderGatesAdd_suffix="_H"   is default  
1.
foo_n.h  or  FooN.h  or  foo n.h  ...
#ifndef FOO_N_H
#define FOO_N_H

#endif   /*FOO_N_H*/

if you set  let g:HeaderGatesAdd_suffix="__"
it could be   FOO_N__
2.
if add let g:insert_extern_c_flag=1 in .vimrc or _vimrc
when you create a new file name foo_h.h  it look like this:
#ifndef FOO_N_H
#define FOO_N_H

#ifdef __cplusplus
extern "C" {
#endif


#ifdef __cplusplus
}
#endif

#endif  /*FOO_N_H*/

3.
:HeaderGatesAdd
this command will change
/**
* @file        foo_n.h
* @version     0.1.00
*/

void test();

to:
/**
* @file        foo_n.h
* @version     0.1.00
*/
#ifndef FOO_N_H
#define FOO_N_H

#ifdef __cplusplus
extern "C" {
#endif

void test();

#ifdef __cplusplus
}
#endif

#endif  /*FOO_N_H*/

4.
let g:HeaderGatesAdd_prefix="__"    
foo_n.h ---------> __FOO_N
5.
let g:HeaderGatesAdd_suffix="_SUFFIX"
foo_n.h ---------> FOO_N_SUFFIX

6.
in case of suffix and prefix both null:
let g:HeaderGatesAdd_gate_type=0 is default
aTestFile.h  ---------> A_TEST_FILE

let g:HeaderGatesAdd_gate_type=1
aTestFile.h  ---------> ATESTFILE

let g:HeaderGatesAdd_gate_type=2
aTestFile.h  --------->aTestFile

may be you have other style,  u can send email to me.
version 1.4 do not require python support
the end please forgive my poor english
 
install details
1.Using [Vundle.vim](Recommend):~
    https://github.com/gmarik/vundle
    After installed vundle and git. Add this line to your vimrc  
    Bundle `'tczengming/headerGatesAdd.vim'`
    Run `:BundleInstall` to install.
    And update them easily by `:BundleInstall!`
2.
   Copy the script file into to the plugin directory of Vimfiles, such as ~/.vim/plugin/
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
headerGatesAdd.vim 1.4 2012-12-12 7.0 帅 得不敢出门 rewrite with pure vim script, do not require python support, test with vim7.3 , perhaps also work with vim6.
headerGatesAdd.vim 1.3 2012-02-02 7.0 帅 得不敢出门 skip c/c++  remarked code block and empty line, then auto insert header gates.
headerGatesAdd.vim 1.2 2011-01-20 7.0 帅 得不敢出门 add   let g:HeaderGatesAdd_gate_type
and  default   let g:HeaderGatesAdd_suffix="_H"  
headerGatesAdd.vim 1.1 2011-01-19 7.0 帅 得不敢出门 add   g:HeaderGatesAdd_prefix    g:HeaderGatesAdd_suffix
headerGatesAdd.vim 1.0 2011-01-19 7.0 帅 得不敢出门 Initial upload
ip used for rating: 216.73.216.46

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github