amVim-for-VSCode icon indicating copy to clipboard operation
amVim-for-VSCode copied to clipboard

Moving cursor across folded code should not automatically unfold

Open rodrei opened this issue 7 years ago • 16 comments

VSCode Version 1.14.1 (1.14.1) macOS Sierra 10.12.5

10e8d29a-bc95-11e6-8686-4c5a30577d75

Reference: https://github.com/Microsoft/vscode/issues/16858

rodrei avatar Jul 18 '17 14:07 rodrei

While this issue is super annoying, a workaround I've noticed on macOS is jacking up key repeat in settings, allows one to skip across folded regions. Though it's still traversing the folded code, it doesn't unfold it.

screen shot 2018-03-08 at 3 16 45 pm

skube avatar Mar 08 '18 20:03 skube

@skube Yes, but this only work if you go pass a short folded code.

This is really an annoying issue that I'll try to fix soon.

aioutecism avatar Mar 12 '18 02:03 aioutecism

It works in long-folded code too, you just have to wait longer for it to come back out. ⏳

I agree though, it's super annoying.

skube avatar Mar 12 '18 17:03 skube

Is there a non-mac workaround? This is extremely annoying.

JulianGindi avatar Sep 19 '18 15:09 JulianGindi

Currently, I use relative line numbers and skip ahead by multiplying my cursor movement by the number of lines indicated after a fold. It's far from ideal.

PZ01 avatar Oct 25 '18 17:10 PZ01

+1

teddyknox avatar Jan 07 '19 06:01 teddyknox

Fixing this issue would make this plugin perfect. Could the solution from vscodeVim be implemented in this plugin?

https://github.com/VSCodeVim/Vim/issues/1004

markovicdenis avatar Jan 14 '19 11:01 markovicdenis

Edit: This has unfortunate side effects (e.g. 10j now shifts the cursor 1 line by 1 line rather than all at once). Leaving the comment here in case anyone wants to try it.

For those using VSCodeVim and still searching,

"vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": ["j"],
            "after": ["g", "j"]
        },
        {
            "before": ["k"],
            "after": ["g", "k"]
        }
]

Fixes the issues for me

waynchi avatar Feb 12 '19 22:02 waynchi

https://github.com/VSCodeVim/Vim/issues/1004#issuecomment-304126779 Set vim.foldfix = true in settings.json.

sabetAI avatar May 07 '19 09:05 sabetAI

VSCodeVim/Vim#1004 (comment) Set vim.foldfix = true in settings.json.

It works, thanks !

xytxxx avatar May 16 '19 20:05 xytxxx

It works great! But, shouldn't this be the default behavior? I really was fed up with the current behavior and at long last searched for it and found above two comments, which helped. Is the vim.foldfix = true too hacky to be set as default?

ceyhunsony avatar Aug 15 '19 14:08 ceyhunsony

Ctrl-d / Ctrl-u still unfolds the code.

Moreover when "foldfix=true" is set moving with those shortcuts is very weird and works as not as expected.

b-ssr avatar Nov 08 '19 19:11 b-ssr

I see, indeed ctrl+d and ctrl+u can still unfold, even though j/k works fine. This issue still needs a fix.

ceyhunsony avatar Nov 11 '19 09:11 ceyhunsony

试一下这个设置 { "key": "k", "command": "cursorUp", "when": "editorTextFocus && amVim.mode != 'INSERT' && amVim.mode != 'VISUAL'" }, { "key": "j", "command": "cursorDown", "when": "editorTextFocus && amVim.mode != 'INSERT' && amVim.mode != 'VISUAL'" }

kola-web avatar Sep 18 '20 07:09 kola-web

This is still open and vim.foldfix = true works on vim extenstion not amvim

alireza-mh avatar Apr 18 '21 12:04 alireza-mh

There is a native vscode's command:

{
  "key": "<>",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == '<>'",
  "args": {
    "to": "prevBlankLine" || "nextBlankLine",
    "by": "wrappedLine",
    "select?": true
  }
}

Example:

{
  "key": "shift+h",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == 'NORMAL'",
  "args": { "to": "nextBlankLine", "by": "wrappedLine" }
},
{
  "key": "shift+t",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == 'NORMAL'",
  "args": { "to": "prevBlankLine", "by": "wrappedLine" }
},
{
  "key": "shift+h",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == 'VISUAL'",
  "args": { "to": "nextBlankLine", "by": "wrappedLine", "select": true }
},
{
  "key": "shift+t",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == 'VISUAL'",
  "args": { "to": "prevBlankLine", "by": "wrappedLine", "select": true }
},
{
  "key": "shift+h",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == 'VISUAL LINE'",
  "args": { "to": "nextBlankLine", "by": "wrappedLine", "select": true }
},
{
  "key": "shift+t",
  "command": "cursorMove",
  "when": "editorTextFocus && amVim.mode == 'VISUAL LINE'",
  "args": { "to": "prevBlankLine", "by": "wrappedLine", "select": true }
}

notiv-nt avatar Jan 23 '22 13:01 notiv-nt

In the upcoming release of amVim extension gj and gk are supported, which will allow you to move over a fold without popping it open. We are also looking into a better way to configure normal arrow keys and j/k to move over a fold, see #303. Please weigh in on the pull request if you have some thoughts. I hope to be able to get a new release out to address this sometime this week.

alisonatwork avatar Oct 30 '22 04:10 alisonatwork

I have just merged the functionality to publish amVim.waitingForInput context (see #303), which will allow those of you using solutions like the one @kola-web provided to more specifically target navigation only and not hijack longer vim commands. This will be released in the upcoming 1.36.0 version. In the mean time, gj and gk are already released in 1.35.0.

I will close this issue for now. Thank you all for the patience and please let us know if you have any further issues.

alisonatwork avatar Nov 13 '22 05:11 alisonatwork