Skip to content

Remove comment when starting new line #305

Answered by bew
kasshedi117 asked this question in Q&A
Discussion options

You must be logged in to vote

This is a builtin feature of nvim, you can control it by tweaking the formatoptions option, see :h formatoptions and :h fo-table.

It's common that this option is overwritten by filetype runtime plugins, in which case you'll need to change it back the way you want.
For example for Lua, you can get your behavior like this:

" In ~/.config/nvim/after/ftplugin/lua.vim
" (to make sure it is run after $VIMRUNTIME/ftplugin/lua.vim which is loaded for every Lua file)
setlocal formatoptions-=o
o   Automatically insert the current comment leader after hitting 'o' or
    'O' in Normal mode.  In case comment is unwanted in a specific place
    use CTRL-U to quickly delete it. [i_CTRL-U](https://neovi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kasshedi117
Comment options

Answer selected by numToStr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants