Vim-Comment-Banners is a Vim plugin which sets up mappings for creating formatted comment banners/boxes. It supports a wide variety of comment banners, including many comment banners used in popular projects such as {TODO}. It is meant to simplify the process of making beautiful configs, the idea being that each user sets up a couple of comment banner mappings and then uses them in any future projects/configs (you can also copy those from the :h CommentBanner page).
TODO
Since most people would want different banners this plugin does not predefine any mappings,
it instead allows you to easily add mappings to your .vimrc
for creating banners:
CommentBannerMapping g1 :CommentBanner --pattern =,1-,= --width 60 --comment false
Produces this output once called with g1 in normal mode on a line which has Title
in it:
==========================================================
------------------------- Title --------------------------
==========================================================
You could use Vim's mapping directly, but this way the CommentBannerMapping command will set up nmap and vmap mappings + operators.
g1
is your mapping.:CommentBanner
is the command provided by the plugin for making comment banners.--pattern
is a flag supplied to:CommentBanner
with the argument of=,1-,=
. The argument is split on,
, where each split is considered the pattern for that line. For simplicity, a pattern is a string of chars which is duplicated until it fills the specified width.--width
is yet another flag which specifies the column for the last character. This is useful to keep the 78 / 80 char limit on some projects. If this is not needed you can supplyauto
which would add just enough characters to cover the title.--comment
specifies whether the banner should be commented out.
Whereas this mapping:
CommentBannerMapping g2 :CommentBanner --pattern =,1-,= --width 60 --comment true
would create this banner (depending on your language):
/* ==================================================== */
/* ---------------------- Title ----------------------- */
/* ==================================================== */
Note that it is still exactly 60 characters wide even with the comment characters.
Checkout the docs (:h CommentBanner
) for further information. These are fairly detailed and have quite a few examples.
Note that this project is still WIP and may still change things around.
Plugin Manager | Command |
---|---|
NeoBundle | NeoBundle 'liquidfun/vim-comment-banners.vim' |
Vundle | Bundle 'liquidfun/vim-comment-banners.vim' |
Vim-plug | Plug 'liquidfun/vim-comment-banners.vim' |
Pathogen | git clone git://github.com/liquidfun/vim-comment-banners.vim.git ~/.vim/bundle/commentbanners.vim |
Author: LiquidFun https://github.com/liquidfun Repository: https://github.com/liquidfun/vim-comment-banners License: same license as Vim