I have my .vimrc set up with indent-based folding.
But when I make additions to a file, the new text is not foldable. I can manually add folds, but I'd rather not.
Is there a way to make vim look over the file and create indent folds for all the current contents?
set foldmethod=indent
set foldenable
set foldlevel=0
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
foldmethod=indent? It's not really clear what you mean. At any rate, note thatfoldmethodis a local option, so you probably want to set it via an ftplugin or an autocommand for the buffers that you care about (rather than setting it once in a vimrc). – D. Ben Knoble Jul 12 '22 at 20:13:setlocal foldmethod=indent foldenable. The folds should definitely be updated as you edit text if thefoldmethodis indeedindent. Also see How to debug my vimrc. How do you know it does apply to text you add? You can check folds with, for example, the foldcolumn – D. Ben Knoble Jul 12 '22 at 20:36:setlocal foldmethod=indent foldenable, the nested stuff folds as expected. Editing answer to includefoldmethod-related stuff from my .vimrc – Aaron Parisi Jul 12 '22 at 21:50