sponsor Vim development Vim logo Vim Book Ad

AutoInclude : Automatically add #include statements for c++ files

 script karma  Rating 6/6, Downloaded by 790  Comments, bugs, improvements  Vim wiki

created by
Py Rho
 
script type
utility
 
description
This script allows you to automatically add the #include statements at the top of you *.{cc,hh} files.
To use it, place the cursor on the type you need to include, then press <;;> and the corresponding #include statement will be added.
In *.cc files, the correct #include is added, and in *.hh files, the forward declaration is added.

Example:
void myfunc (Foo* x);
-> if you place the cursor on "Foo" and press <;;> (just the 2 semicolons), the #include "foo.hh" will be added at the top of the file. (The insertion location is specified by a variable, see Install Details).

The naming standard used is "Foo" and "FooBar", for the FooBar class the #include will be: #include "foo-bar.hh".
 
install details
Just put the autoinclude.vim file in your ~/.vim/plugin directory.
You can specify the line where the #include will be added with the g:AutoIncludeLine variable.
Just add this line to your ~/.vimrc file:
let g:AutoIncludeLine = 42
Where 42 is the line number.
 

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
autoinclude.vim 1.0 2008-06-20 7.0 Py Rho Initial upload
ip used for rating: 18.118.140.108

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github