Question

Here is my entire .vimrc:

set ignorecase
set scs
let perl_fold=1
hi Folded cterm=bold ctermfg=yellow ctermbg=lightblue
set modeline
set hidden

When loading a .pm file (which usually contains just a single package), all of the file's code is folded into a single line, and the first thing I have to do is to expand that fold.

Is there a way to have vim automatically expand that fold after loading the file? I em envisioning some sort of post-load hook which would allow me to say if the entire file (or more than 90%) is folded into a single line, then automatically expand that fold. (The "more than X %" condition might be needed if there are blank lines at the beginning of the file since they don't get folded.)

Was it helpful?

Solution

You could try (in your vimrc:

au BufReadPost *.pm normal zo

For reference: :help :autocmd, :help BufReadPost

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top