By default, Vim will fold everything it can if folding is enabled. This can be useful from big complicated files, but it tends to get in the way for smaller, simpler files.For example, if I open a code file that contains just one class, it makes no sense to have that class folded.I think a reasonable metric for whether folding should happen, is the length of a file. If the file is much bigger than the terminal you're viewing it in, folding is probably beneficial. If it would (nearly) fit on a page unfolded, folding is probably more of a hindrance than a help.Is there a way to make Vim only enable folding only if the file you're opening is longer than some size?
How can I enable folding only for files longer than a certain length?
vimrc;folding
You can use the line() function to fold or unfold your file: In your vimrcif line('$') > 20   set foldlevel = 1endifline('$') returns the line number of the last ($) line of your document.Of course, this is executed only when you are launching Vim, so you can use a autocommand like so:autocmd! BufReadPost * :if line('$') > 20 | set foldlevel=1 | endif