If I'm typing a comment in gVim like this
// this is a comment
and I hit ENTER, it will automatically start the next line with //, so it looks like this:
// this is a comment
//
But usually I don't want to write more comments when using this commenting style. Can I stop gVim from automatically doing this, while still keeping the auto-completing of the /* .. */ commenting style?
To permanently disable this behavior, add autocmd FileType * set formatoptions-=cro in your . vimrc / init. vim .
Using the up and down arrow key, highlight the lines you wish to comment out. Once you have the lines selected, press the SHIFT + I keys to enter insert mode. Enter your command symbol, for example, # sign, and press the ESC key. Vim will comment out all the highlighted lines.
To disable it while hitting ENTER in insert mode, do :set formatoptions-=r
To disable it while hitting o or O in normal mode, do :set formatoptions-=o
See :help 'formatoptions'
and :help fo-table
.
Alternatively, you can still press CTRL-U in insert mode if you want to delete characters from start of line till the cursor.
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