ru Русский

Reticularium

NETWORKS PLACE

The subject is extremely annoying. I am not that lazy to add a comment symbol myself. This would be a good idea though, if it wasn’t sometimes needed to insert blocks of code via clipboard. With auto-comment on, if I insert

some line
# some comment
some line

I get

some line
# some comment
# some line

because there is a CR at the end of commented line and the auto-comment function adds the # symbol to the next line automatically.

The real problem begins when you try to insert many lines with some of them commented. You end up with each line after the first comment commented, the next comment commented twice so the next lines all commented twice and so on.

The solution:

Add this to your vimrc file:


au FileType * setl fo-=cro

where:

  • au = autocmd
  • FileType * – any file type
  • setl = setlocal
  • fo = formatoptions
  • -=cro disables c, r and o options ( see documentation )