对于 vim,默认的单行注释开头是“//”。我想将其更改为“//”(在//后添加一个空格)。我应该更改评论选项吗?或者还有其他方法可以实现吗?
谢谢。
最佳答案
" .vimrc
" It's better to change it only for specific types of files
autocmd FileType c,cpp let b:comment_leader = '// '
" Comment a text block by selecting it in V mode and pressing \cc
noremap <silent> <leader>cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
" Also
autocmd FileType c,cpp setlocal comments-=:// comments+=b://
关于vim - 如何更改vim中的单行注释前导符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10680022/