Apple
Apple

Reputation: 351

Automatic insertion of comment leader not working vim

I can't seem to get the formatoptions to work in the general case for vim.

I have filetype plugin on and in many of the default plugins there's a line saying setlocal fo-=t fo+=croql and after reading the vim docs I saw that was where the automatic insertion of the comment leader was coming from. I liked this, but it wasn't happening in python, (because the formatoption line wasn't in the default plugin) so I put the line (except with set fo+=crotl) in my .vimrc.

It doesn't seem to have done anything, the comment leader is still not inserted in python (or bash which also doesn't have the line in the default plugin). I've also tried putting the line in my .vim/after/ftplugin/python.vim file (both as setlocal and set, and it hasn't done anything there either.

My question is - are there any options that will override this action that I should look out for? else, what could be the reason it's not working?

Thanks in advance

EDIT:

I should note also: in the python buffers :set formatoptions? shows that the options have been set, they just don't work.

Upvotes: 0

Views: 309

Answers (1)

Apple
Apple

Reputation: 351

I just found out - The options were working, it was just that the comments were set with

set comments=...,b:#,...

and after looking that up, I found the 'b' means vim only counts the line as a comment if there is whitespace after the #, as I wasn't putting the space there, vim didn't count it as a comment and hence didn't apply the formatoptions set for comments.

Upvotes: 1

Related Questions