Question

Fold 3 below fold in lines below the end of the function. How can I make this fold in the expected way (to preserve the lines below the end of function):

Code :

(function() {
        var w = window; // <-- FOLD 1 pressed HERE
        function pqdoitall () {
                // insertScript
                // fr2window 
                // pqinsert2windowDoc
                // pqinsert2window
                // runit
                //runit(); // <-- FOLD 2 pressed HERE
        } // pqdoitall
        w.addEventListener("load",pqtdoitall);
        pqtdoitall(); // <-- FOLD 3 pressed HERE
})();

Fold 1 Result:

(function() {----------------------------------------------------------------------------

Fold 2 Result:

(function() {
        var w = window;
  function pqdoitall () {----------------------------------------------------------------

Fold 3 Result:

(function() {
        var w = window;
  function pqdoitall () {----------------------------------------------------------------

This is quite annoying since I would like to see the two lines below the function terminating brace when I fold it.

Foldmethod lines in ~/.vimrc (as per this answer) :

set foldmethod=syntax
set foldlevelstart=1

let javaScript_fold=1         " JavaScript
let perl_fold=1               " Perl
let php_folding=1             " PHP
let r_syntax_folding=1        " R
let ruby_fold=1               " Ruby
let sh_fold_enabled=1         " sh
let vimsyn_folding='af'       " Vim script
let xml_syntax_folding=1      " XML 
Was it helpful?

Solution

OK. While this is not a real answer to your question, I've found the syntax folding method a lot more disappointing than the "dumber" indent method which produces more coherent results across languages.

set foldmethod=indent is all I use.

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