If you’re editing a file of the vim
filetype, Vim might by default insert the comment character (in Vimscript, this would be "
) at the beginning of each new line you enter after a comment. As already mentioned, this is a result of Vim’s formatoptions
setting.
To turn this behavior off in the current file, run
:set formatoptions-=ro
To turn it off by default, add this to your ~/.vimrc
:
set formatoptions-=ro
To turn it off for Vimscript files, add this to your ~/.vimrc
:
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal formatoptions-=ro
augroup END
r
and o
are options which can be given to formatoptions
. For the full list of possible options, run :help fo-table
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…