Vim: Folded code unfolds if you spend some (unknown number) of ms idle in a fold
- Click thumbs-up š on this issue if you want it!
- Click confused š on this issue if not having it makes VSCodeVim unusable.
The VSCodeVim team prioritizes issues based on reaction count.
What did you do?
Scrolled through folded code once with the j
key held down, another time pressing it over and over.
What did you expect to happen?
Folded lines were skipped.
What happened instead?
Cursor did not skip the folded lines (watch the line numbers in the gif).
Technical details:
- VSCode Version: 1.6.1
- VsCodeVim Version: 0.4.0
- OS: macOS Sierra (10.12)
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 765
- Comments: 73 (18 by maintainers)
Commits related to this issue
- Merge pull request #1552 from Chillee/foldfix Fixing the automatic fold expansion (#1004) — committed to VSCodeVim/Vim by Chillee 7 years ago
- Add fold fix from https://github.com/VSCodeVim/Vim/issues/1004#issuecomment-304126779. — committed to theherk/commons by theherk a year ago
We just pushed out a new version, so enable
vim.foldfix
and tell us what you think!Itās a hack and not a proper solution to this problem, so weāll probably leave this issue open for now.
+1 for this. Having my folds open while Iām navigating is quite frustrating. I find myself having to use my mouse to reposition my cursor, which should make all of us sad.
+1 comments arenāt going to do anything but annoy the repo owners. Please use the š reaction on the original post instead. Be kind to repo owners and other subscribed users.
š Itās okay. We generally use thumbs up as a measure of importance, but the extra signal we get from people who were so bothered they had to come and leave a comment is a little useful too. Weāre definitely aware this one is painful - weāll try to fix it as soon as we can!
I polished up my fix over here: https://github.com/VSCodeVim/Vim/pull/1552
It does some hackish stuff, but it seems to work great for me. Hereās a pretty bad demo:
I can confirm what @pizzooid has noted, that
gj
andgk
correctly step over folded sections even withoutvim.foldFix
enabled. If you want to use this as a workaround, you can add the following to your settings JSON:Would it make sense to make this the default behavior for the plugin? Or would this be too unexpected for folks who are used to traditional vim behavior for
j
andk
?Update 2019-02-26: Iāve updated the settings to handle the
$
and^
movements correctly.I agree with @Chillee . Maybe some one should reopen the issue with vscode? It has been a couple of years maybe it can be prioritized.
sorry to say, but this makes the extension useless for me.
greetzā¦
I have only
"vim.foldfix": true,
in my settings and it works fine, both with j, k and upArrow, downArrow.with
foldfix
it works withj
/k
, butctrl-u
/ctrl-d
{
/}
(shift-[
/shift-]
)10-
/10+
(relative jump)still open collapsed fold.
vscode just close Microsoft/vscode#22276, they will not consider this feature in the next 6-12 months roadmap.
Iāve created a new issue about it, go and vote! š
https://github.com/microsoft/vscode/issues/81498
To add on this, you can use the following settings to make it more jump like:
Its been almost two years since microsoft/vscode#22276, maybe itās worth to try again?
after set
foldfix
,j
/k
works fine to skip fold, butctrl-u
/ctrl-d
still break the fold.Can you make this a default option, not everyone know about this, I just want to open an issue then when I search again on google, finally I landed on this, or at least the issue should be pinned down.
Thank you for brigging the foldfix, I really frustated with how the cursor open all fold
As an alternative to CTRL-u & CTRL-d Iāve been using H & L which do not break the fold.
I would suggest to use
vim.normalModeKeyBindingsNonRecursive
andvim.visualModeKeyBindingsNonRecursive
to make sure we avoid nasty recursive loops. Other than that, I can only confirm this is a working workaround! Cheers! š@gschintgen Unluckily, the best solution is to not set
foldfix
to true for most people šI would say āpartially fixedā. I can navigate over folds but if i initiate a fold from inside from anywhere but the top of of the folding block then it immediately unfolds. This is certainly better than before though. VSCode v1.12.2 Vim v0.8.4
I just found noticed that
gj
works properly withoutvim.foldfix
enabled. Is that because of the fix, or would that be a different method for building foldFix?@Phrohdoh for example
25gg
will take you to 25th line not the beginning i meant end of the block by last line@desprit The issue isnāt closed. As far as I know (itās been a while since Iāve looked into this very closely), thereās nothing we can do unless VSCode expands its API to give us more information about folded regions.
The
j
togj
bind is undesireable, IMO.gj
wonāt ārememberā which column you were at when pass an empty line.gj
will result in: line 1: column 45 line 2: column 0 (empty line) line 3: column 0j
will result in: line 1: column 45 line 2: column 0 (empty line) line 3: column 45With
foldfix
enabled, relative jumping is no longer instant, and it is inaccurate when jumping over a fold.there was a response here from a maintainer of vscode suggesting a solution to this.
Wouldnāt a good solution to this be a vscode api where
cursorDown
just has a new boolean argument that is something likeopenFolds: false
. It seems like they are open to thatThe biggest downside in theory is that it deviates from the expected vim behavior.
gj
/gk
are the commands for move the cursor around wrapped lines, which means if youāre expecting to jump over wrapped lines the same way it jumps over folded lines, then itāll be a bit confusing (since it effectively jumps into the middle of a wrapped line). This behavior is acceptable for me, but might be undesirable for vim purists (though tbh I also donāt know how the real vim handles folding š¤·āāļø).The other issue is that Iām not sure those keybindings are quite complete. For example
$
/^
arenāt modified, so they still treat wrapped lines like a single line, whilej
/k
now treat wrapped lines as multiple different lines. Iāve also noticed that some cursor motions while working with wrapped lines donāt quite work as expected, though I havenāt yet figured out whatās going on there. Iāll update my comment if I find any other improvements šPRs welcome
Hi, itās a pity that I canāt really use code folding due to this issue.
I tried foldfix=true (which seems to work fine), but unfortunately it leads to very laggy behaviour: If I keep j or k pressed in order to move up or down in a source file, the cursor continues to move down or up even after I let go of the movement key. The cursor is playing catch-up.
This is 100% reproducible on my machine (4th gen. mobile i7) and even happens when I donāt have any folded code parts!
Do note that even though my comment may sound negative, Iām very grateful for the active development of this extension!
@rogersachan Thereās been a significant amount of discussion on the VSCode repo, and itās a very nontrivial task. Take a look at https://github.com/Microsoft/vscode/issues/22276
@meherranjan I agree. Itās an ugly hack, which is why itās not enabled by default and why this issue remains open.
Good catch, @zwing99! Iām seeing the same thing on my end, as well.
Oops now Iām spamming (I didnāt mean to close this).
+1 for fixing this asap