Vim Tips Wiki

Insert comment boxes in your code

Redirected from VimTip900

1,623pages on
this wiki
Add New Page
Add New Page Talk0
Tip 900 Printable Monobook Previous Next

created March 22, 2005 · complexity intermediate · author Ken Holm · version 5.7

Put this in your vimrc and you can have nicely aligned comment boxes:

map ,co O#====================================================================================================<CR>#<CR>#====================================================================================================<Esc>100\|Dkk100\|DjA


  • The above should all be on one line.
  • There is a space after the "A" at the end of the line above.
  • While in navigation mode use ,co to create a comment block.
  • The comment block will chop off at column 100.
  • It relies on having autoindent set.


This should have the same result, I believe:

map ,co O#<Esc>100A=<Esc>100\|D<CR>i#<CR><Esc>i##<Esc>100a=<Esc>100\|D<Esc>kA

Also on Fandom

Random Wiki