tpope / vim-commentary

commentary.vim: comment stuff out
http://www.vim.org/scripts/script.php?script_id=3695
5.9k stars 214 forks source link

Python: New Line "o" does not start as commented line in NeoVim #130

Closed dseeni closed 4 years ago

dseeni commented 4 years ago

Hey Tim,

Pretty new to code/vim so forgive me if this is my fault. I think that in NeoVim starting a new line with "o" from a commented line in a python file does not produce a new commented line.

I tested with just commentary active, and it does not behave like any other file type (lua, vim, powershell, etc)...

yochem commented 4 years ago

Hi,

Open a python file in neovim and run this command: :echo &formatoptions. Is the letter o in this?

From :help fo-table:

o   Automatically insert the current comment leader after hitting 'o' or
    'O' in Normal mode.

If this is not the case and you want to input a new comment when hitting o, add this to your init.vim: autocmd FileType python setlocal formatoptions+=o

dseeni commented 4 years ago

@yochem thank you! Had no idea bout the fo-table.

yochem commented 4 years ago

Me neither ;)

Jumping through the help pages is pretty fun. I knew about formatoptions and found out about fo-table via :help formatoptions.