-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document display line movement best practices #3623
Conversation
To vertically move to wrapped lines when word wrap is on. Ref: #2403 (comment) Ref: #2924 (comment)
Travis tests have failedHey @karlhorky, Node.js: 8if [[ $(git diff-index HEAD -- *.js *.ts *.md) ]]; then git diff; echo "Prettier Failed. Run `gulp forceprettier` and commit changes to resolve."; exit 1; fi
❤️ ContributingThis project is maintained by a group of awesome people and contributions are extremely welcome ❤️. For a quick tutorial on how you can help, see our contributing guide.
|
Travis tests have failedHey @karlhorky, Node.js: 8if [[ $(git diff-index HEAD -- *.js *.ts *.md) ]]; then git diff; echo "Prettier Failed. Run `gulp forceprettier` and commit changes to resolve."; exit 1; fi
❤️ ContributingPrettier Failed. Run [10:27:02] Using gulpfile ~/build/VSCodeVim/Vim/gulpfile.js
|
Prettier has some strange styling for the configuration objects. Maybe we can disable it for this code block? diff --git a/README.md b/README.md
index 904f215..6350df3 100644
--- a/README.md
+++ b/README.md
@@ -642,7 +642,7 @@ Vim has a lot of nifty tricks and we try to preserve some of them:
If you have word wrap on and would like the cursor to enter each wrapped line when using <kbd>j</kbd>, <kbd>k</kbd>, <kbd>↓</kbd> or <kbd>↑</kbd>, set the following in VS Code's keybindings.json settings file ([other options exist](https://github.com/VSCodeVim/Vim/issues/2924#issuecomment-476121848) but they are slow):
```json
- {
+ ({
"key": "up",
"command": "cursorUp",
"when": "editorTextFocus && vim.active && !inDebugRepl && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
@@ -661,10 +661,9 @@ Vim has a lot of nifty tricks and we try to preserve some of them:
"key": "j",
"command": "cursorDown",
"when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Normal' && !suggestWidgetMultipleSuggestions && !suggestWidgetVisible"
- }
+ }) |
Switch to keybindings instead of settings Ref: VSCodeVim/Vim#3623 Ref: VSCodeVim/Vim#2924 (comment)
Sorry for the delay in review, we had a 👶 recently so my spare time is pretty much filled with 🍼 and 😴 . Seems reasonable. Feel free to disable it for all MD files; it'd be harder to maintain special casing specific blocks. |
Great, cheers for the feedback.
I'm not sure I understand here... Won't this also be needed for visual line movement across word wrapped Markdown files? |
My request was to disable whatever rule prettier requires for wrapping |
Err, that (2d34a56) is exactly what I don't want. Can we just disable that specific rule globally for MD files? Does prettier have that option? |
Hm, not really, Prettier doesn't work like ESLint in disabling certain rules - it's low-configuration by philosophy. So unless we want to disable all of the Markdown formatting everywhere ( |
Lame. |
and merged. Thanks! |
This has the drawback of breaking motions that involve j/k. For example
Any better way of getting around this so I could still use |
@alexpattison ah, sorry about that. I've opened #3670 to document this and reword the note about the less-performant alternatives. |
Thanks for posting these keybindings, very helpful. I'm using the VSCode Vim extension. When I add the keybindings mentioned at the top of the thread, things work great in Normal mode, but when I'm in Visual mode or Visual Line mode, using
and this does move the cursor by visual line, but it doesn't expand the highlighted region correctly to match the cursor position. Any ideas how to get this to work when in Visual / Visual Line mode? |
@dwadden Oh weird, the bindings work for me in visual and visual line modes 😕 Wonder what's going on... My VS Code is at version My keybindings: Here's a gif of it working: |
Hey @karlhorky thanks for looking at this. The issue only comes up when line wrap is toggled on. Here's a gif to show what I mean. When visual mode is off and I press |
Ah I understand now, ok... I believe this is also happening for me in visual mode - will test in the next few hours. I wonder if this is actually possible with these key bindings. Maybe the less performant option would work here: |
Yep, can confirm that this is happening for me too. Not sure about a good workaround here... I tried adding the code at the bottom in
These issues may be related to #1323. // Caution: Buggy!
"vim.visualModeKeyBindingsNonRecursive": [
{ "before": ["j"], "after": ["g", "j"] },
{ "before": ["k"], "after": ["g", "k"] }
], |
OK glad you can reproduce. Has a fix actually been merged? |
I didn't report an issue regarding this yet, so I don't think there's been any work on it. I think that unless we find another solution, it's just a limitation of VSCodeVim for now (this limitation is also present using my workaround in amVim). |
OK sounds good. Thanks! |
This is such a hack but it seems to work to go past the blank line on the way back up (the issue that @karlhorkey showed above. Just added a little movement before
|
Ah thanks for this @1dancook! At the moment I'm using amVim, but this seems like it could be useful! Wish this was just a built-in setting so that we wouldn't have to resort to using these hacks. I'll have to check out VSCodeVim again some time in the coming months to see if it's more friendly with the default VSCode setup (the reason I'm using amVim now). cc @J-Fields |
Solution described here is not working for me as it breaks Visual and VisualLine modes completely. 😕 |
Do you mean that the J and K keys don't move down a single display line in word wrap mode as mentioned above in #3623 (comment) ? Or do you have a different problem? I'm assuming you meant you tried out the other fix in #2924 (comment) rather than #1323? |
So what I tried is placing this into my
With this VisualLine mode doesn't activate at all. Normal Visual mode activates but can't go up/down to the next display line. This works better in
But only until you hit an empty line which break the cursor movement. Also the cursor doesn't keep vertical position for some reason. |
I let k and j behave natively as they should in Vim, and configure the up and down arrows to move across wrapped lines as typically desired in prose writing: In VSCode settings.json, I added the following: In VScode keybindings.json, I added the following: |
If one wants to set up j and k to move across wrapped lines in normal and visual mode, while enabling up and down arrows to move across wrapped lines in normal, visual, and insert mode, one may use the following VSCode configurations: Add the following in the settings.json: { |
Thanks for this project! It's really great to be able to use most common things from Vim in VS Code!
What this PR does / why we need it:
Best practices are not documented for how to vertically move to wrapped lines when word wrap is on.
Ref: #2403 (comment)
Ref: #2924 (comment)
Which issue(s) this PR fixes
This documents the movements in a FAQ item:
How can I move the cursor by display line with word wrapping?
If you have word wrap on and would like the cursor to enter each wrapped line when using j, k, ↓ or ↑, set the following in VS Code's keybindings.json settings file (other options exist but they are slow):
Special notes for your reviewer:
In case I've missed some case in which rebinding j and k in
Normal
mode and ↓ and ↑ in all modes to the VS Code default would cause a problem, please let me know and we can change this.