Reputation: 143895
There's something weird going on in my fortran folding. This is the example file
module foo
contains
subroutine hello()
end subroutine hello
subroutine hello()
end subroutine
subroutine hello()
end subroutine
end module foo
subroutine hello()
end subroutine
subroutine hello()
end subroutine
subroutine hello()
end subroutine
and this is the vimrc
syntax on
au! BufRead,BufNewFile *.f90 setfiletype fortran
set foldmethod=syntax
let fortran_fold=1
The annoying thing is the following. If I cut (dd) and paste (P) a folded subroutine outside the module/end module block, the freshly pasted fold stay closed. If I paste it inside the module/end module block, the newly pasted folded region appears instead unfolded. Can you reproduce the issue (vim 7.2 here) and do you know any workaround/fix ?
Upvotes: 2
Views: 397
Reputation: 67147
I think that's no specific fortran-module problem but a general one.
There's a vimtip that provides a solution for accidently opening folds when going to edit a file. The trick is to set the foldmethod
to manual
when editing starts:
autocmd InsertEnter * if !exists('w:last_fdm') | let w:last_fdm=&foldmethod | setlocal foldmethod=manual | endif
When you're done with editing (or leave the window), reset foldmethod
to it's original value:
autocmd InsertLeave,WinLeave * if exists('w:last_fdm') | let &l:foldmethod=w:last_fdm | unlet w:last_fdm | endif
Upvotes: 2