Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Going to next line using j unfolds folded code

Open alcazoid opened this issue 10 years ago • 3 comments

To reproduce:

  1. set the cursor to the start of a function
  2. fold it(default binding is Ctrl+=)
  3. press j to move to the next line
  4. code unfolds

Without Vim plugin we are able to move past the folded code without it being unfolded.

alcazoid avatar Mar 13 '15 09:03 alcazoid

Not able to reproduce locally using examples from CodeMirror's demo. Can you provide some subset of the code that exhibits this behavior? Fwiw, if this behavior is also present in CodeMirror, the appropriate place to report this will be CodeMirror

cldwalker avatar Mar 13 '15 13:03 cldwalker

def hi():
    print "hi"
    return

hi()

This python code does it for me.

  1. Go to line 1(with def)
  2. Press Ctrl+= to fold it
  3. Press j to go one line down
  4. Code gets unfolded

alcazoid avatar Mar 15 '15 23:03 alcazoid

In CodeMirror vim mode, j, k will unfold code as the cursor moves into folded lines. Using gj, gk will solve this problem.

j,k: moveByLines gj, gk: moveByDisplayLines

You can create mapping if it feels more convenient.

codeMirror.Vim.map('j', 'gj', 'normal');
codeMirror.Vim.map('k', 'gk', 'normal');

leafOfTree avatar Nov 19 '19 05:11 leafOfTree