Reputation: 12423
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.
Upvotes: 3
Views: 1882
Reputation: 41
Maybe you are looking for something similar like scrolloff
in vim?
Then add this to you settings.json
:
"editor.cursorSurroundingLines": 9999,
Upvotes: 3
Reputation: 46787
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"
}
Upvotes: 7
Reputation: 59
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!
Upvotes: 3