For vim, the default single-line comment leader is "//". I want to change it to "// " (add a space after //). Should I change comments option? Or is there any other way to make it?
Thanks.
" .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://
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