I am facing the following problem: a function, triggered by a :nnoremap
inserts a few lines into a buffer. Since I have folding enabled with foldexpr=...
and the inserted text contains this expression, the inserted text is folded.
I could stop this unwanted behaviour by setting nofoldenable
. Yet, if I do that, the already existing folds are opened. This is also not what I want. The existing folds should stay as the are, opened or closed.
So, is it possible to tell vim somehow that the inserted text is to be inserted without trying to fold it?
:silent! :normal! zO
inside your function?zO
and friends work recursively on folds under the cursor, but inserting text in a function doesn't necessarily happen at the cursor position (append()
, for instance, appends by line number and doesn't move the cursor; neither does it set the'[
,']
marks).