How do i prevent neovim commenting out next line after a comment line?

When I comment out some line and hit enter neovim automatically comments the next line out. This is particularly problematic when pasting from the clipboard. If the snippet contains comments neovim goes ahaed and comments everything out after that point. How do I disable this “smart commenting”!!! ?

Just figured it out.

set formatoptions-=cro

see following for details

:h 'formatoptions'
:h fo-table
1 Like

I had the same issue! Most people I know do too. I feel like it should be defaults.

Use :set paste to disable vim’s various helper features (auto comment, auto indent, auto line-wrapping, etc) when pasting while in insert mode. That way you can toggle everything at once while still keeping these features regularly. :set nopaste to go back.

I have neovim configured to paste from my system clipboard so i never need to toggle paste mode so i just p normally.

wow this is particularly helpful thanks :slight_smile:

In my ~/.config/nvim/after/ftplugin/lua.lua I have:

 vim.opt_local.formatoptions:remove({ 'r', 'o' })