Ⅰ. 插件描述
Add the #ifndef/#define/#endif guard to a C/C++ header fileⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/addifndefguard'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/addifndefguard'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/addifndefguard'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/AddIfndefGuard
Ⅳ. 文档说明
When one writes a header file for C/C++, compile errors will occur if the same header script is included more than once. A common solution is to add
#ifndef FILENAME_H
#define FILENAME_H
to the start of a file, and
#endif
to the end. This solves the problem.
However this is mechanical and routine. So the computer should do it. So here's a script to do it.
It will add those lines to the top of the file you call it in. It will change FILENAME to be the uppercase name of that file, ommiting the file extension. It will not (yet) check to see if a #define/#ifndef/#endif black has already been added. It will not check the filename, so it can be called on anyfile.