Answer a question

When scrolling down in VSCode. Using arrow keys makes you have the cursor on the bottom. I can use Ctrl + Arrow Down This scrolls the screen and the cursor keeps its position. In this case I need to click on the new line in order to start editing. However I'm looking for a way to scroll and move the cursor. For example if I'm in the middle of the screen I want to scroll and get the cursor to maintain its relative position in the middle.

Has anyone done this?

Answers

With the help of the extension Multi Command

Add this setting

  "multiCommand.commands": [
    {
      "command": "multiCommand.up1LineKeepCursor",
      "sequence": [
        {"command": "editorScroll", "args": {"to": "up", "by": "line" }},
        "cursorUp"
      ]
    },
    {
      "command": "multiCommand.down1LineKeepCursor",
      "sequence": [
        {"command": "editorScroll", "args": {"to": "down", "by": "line" }},
        "cursorDown"
      ]
    }
  ]

And these keybindings

  {
    "key": "shift+ctrl+alt+up",
    "command": "multiCommand.up1LineKeepCursor",
    "when": "editorTextFocus"
  },
  {
    "key": "shift+ctrl+alt+down",
    "command": "multiCommand.down1LineKeepCursor",
    "when": "editorTextFocus"
  }

You can use any key binding you like.

It works good when Word Wrap is OFF.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐