1

With my default settings, theformatoptions flag is tcq for text files, and croql for C++. I don't like that it autowraps the text, so I put this into my vimrc:

autocmd FileType text set formatoptions-=t

So far, this works as expected. Now I want to turn on comment joining on C++, so I add the following line to my vimrc just after the above line:

autocmd FileType c,cpp set formatoptions+=j

Now the formatoptions becomes croqlj for every file, not just C/C++, but also for text. Why is this?

1 Answer 1

0

'formatoptions' is a buffer-local option; you should use :setlocal instead of :set.

With the latter, you not only change the option for the current buffer, but also modify the global default for any future buffer that gets opened.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .