I am making the switch from TextMate to Vim for all of my text editing. However, one of the features that I used a lot in TextMate was the comment banner command (ctr-shift-b
). It would create a banner and allow you to enter text inside the banner, and the banner would adjust to the length of the text. Is there any plugins, or any similiar feature in Vim? If not, is there a way I can program vim to make a comment banner? Any suggestions would be great. Thanks!
I've got these lines in my .vimrc
:
autocmd FileType vim map <leader>ccb I"<Del> <Esc>A "<Del><Esc>yyp0lv$hhr"yykPjj
autocmd FileType javascript,php,c map <leader>ccb I// <Esc>A //<Esc>yyp0llv$hhhr-yykPjj
autocmd FileType python,ruby,sh,zsh map <leader>ccb I# <Esc>A #<Esc>yyp0lv$hhr-yykPjj
autocmd FileType css map <leader>ccb I/* <Esc>A */<Esc>yyp0llv$r-$hc$*/<Esc>yykPjj
In .vimrc
it turns this:
vimrc banner
into this:
""""""""""""""""""
" vimrc banner "
""""""""""""""""""
In a JS file it turns this:
javascript banner
into this:
//---------------------//
// javascript banner //
//---------------------//
Etc.
" Creating underline/overline headings for markup languages
" Inspired by http://sphinx.pocoo.org/rest.html#sections
nnoremap <leader>== yyP^v$r=jyyp^v$r=
nnoremap <leader>** yyP^v$r*jyyp^v$r*
nnoremap <leader>= yyp^v$r=
nnoremap <leader>- yyp^v$r-
nnoremap <leader>^ yyp^v$r^
nnoremap <leader>" yyp^v$r"
I wish I'd keep a link to where I found it, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With