How can I keep the text cursor (caret) on the screen when scrolling in VS Code with Ctrl + up/down?
I've searched for scroll options, text options, extensions, etc. To no avail.
This is what I'm using in keybindings.json and it pretty much matches Visual Studio's Ctrl+Up/Down behaviour. (ie: basically SebastianDB's answer but for both keys and line up/down instead of page. Also, you don't need the macros extension, it works out of the box).
{
"key": "ctrl+up",
"command": "editorScroll",
"args": {
"to": "up",
"by": "line",
"revealCursor": true
},
"when": "editorTextFocus"
},
{
"key": "ctrl+down",
"command": "editorScroll",
"args": {
"to": "down",
"by": "line",
"revealCursor": true
},
"when": "editorTextFocus"
}
I haven't tried this myself but have you looked at this yet?
Install this:
https://marketplace.visualstudio.com/items?itemName=geddski.macros
then add a macro to ctrl+up/down with this sample and change the key from alt+pageup to what you want.
https://github.com/Microsoft/vscode/issues/22796
{
"key": "alt+pageup",
"command": "editorScroll",
"args": {
"to": "up",
"by": "page",
"revealCursor": true
},
"when": "editorTextFocus"
}
Hope it works, have a good one!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With