Reputation: 363
My problem is that when I press CTRL + up or down arrow, the cursor doesn't move when it reaches the border of the page, and therefore when I release the CTRL button, the page "bumps" to where the cursor is.
Is it possible to change this behaviour?
For example in Visual Studio IDE, the cursor is "anchored" to the top of the page if you press CTRL + down arrow.
Thanks in advance.
Upvotes: 16
Views: 5251
Reputation: 235
There is a workaround.
Edit your keybinding.json and add this:
{
"key": "ctrl+up",
"command": "editorScroll",
"when": "editorTextFocus",
"args":
{
"to": "up",
"by": "line",
"revealCursor": true
}
},
{
"key": "ctrl+down",
"command": "editorScroll",
"when": "editorTextFocus",
"args":
{
"to": "down",
"by": "line",
"revealCursor": true
}
}
Upvotes: 21
Reputation: 3801
If you wanted to keep the cursor where it was on the screen, you can do the followings:
First install the multi-command extension to VSCode.
Open your the settings JSON and paste these commands into it:
"multiCommand.commands": [
{
"command": "multiCommand.keepCursorPosScrollUp",
"sequence": [
{
"command": "editorScroll",
"args":{
"to": "up",
"by": "line",
"revealCursor": false
}
},
"cursorUp"
]
},
{
"command": "multiCommand.keepCursorPosScrollDown",
"sequence": [
{
"command": "editorScroll",
"args":{
"to": "down",
"by": "line",
"revealCursor": false
}
},
"cursorDown"
]
}
]
Open your keyboard shortcuts JSON and paste the followings into it:
{
"key": "ctrl+up",
"command": "extension.multiCommand.execute",
"args": {
"command": "multiCommand.keepCursorPosScrollUp"
},
"when": "editorTextFocus"
},
{
"key": "ctrl+down",
"command": "extension.multiCommand.execute",
"args": {
"command": "multiCommand.keepCursorPosScrollDown"
},
"when": "editorTextFocus"
}
Save the files, you're done. :)
Upvotes: 0