I have two opening buffers and one has foldenable and foldmethod=indent, other has nofoldenable and foldmethod=syntax.

I need that when I move between buffers, each buffer has it own fold settings and for example a buffer keeps folded even I move to other buffer that has nofoldenable

Can we achieve this?

Vim 8.1 / Archlinux

2 Answers 2


If by move between buffers you mean -- doing it with a single window (no splits) then the only(?) option is to use autocommands. As an example:

augroup fold_params | au!
    au BufRead,BufNewFile *.py :setl fdm=indent | setl foldenable
    au BufRead,BufNewFile *.c :setl fdm=syntax | setl nofoldenable
augroup end

Options foldmethod and foldenable are local to window so you have to redefine them as soon as you open other file/buffer in the same window.


We can achieve this by set setlocal for python file and nofoldenable in global in .vimrc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.