0

When I hit the keyboard shortcut to gotoLine in vscode, it opens the drop down window. Once I type in the line number, I would like the keyboard shortcut that opened the gotoLine pallete, to also execute the gotoline and close the pallete.

For example I have tilde key mapped to gotoLine.

When I enter the line number, I would like it to behave such that when I hit tilde again, it acts as if I hit enter (not escape).

Is there a way I can do that with keymappings in vscode?

Scorb
  • 1,654
  • 13
  • 70
  • 144
  • [This](https://stackoverflow.com/questions/37009184/multiple-actions-on-one-keyboard-shortcut-in-vscode) might help you. – itsmysterybox Oct 28 '18 at 21:39

1 Answers1

0

When you say you mapped to the tilde, I don't know what kind of keyboard you are on, but on my keyboard the tilde ~ is shifted on the same key as the backtick ` so I used that below. But you could use whatever key you wish instead.

  {
    "key": "`",
    "command": "workbench.action.gotoLine",
    "when": "!inQuickOpen"

  },
  {
    "key": "`",
    "command": "workbench.action.acceptSelectedQuickOpenItem",
    "when": "inQuickOpen"
  },

  // you may not care about disabling the default open quickOpen:gotoLine
  {
    "key": "ctrl+g",
    "command": "-workbench.action.gotoLine"
  }
Mark
  • 143,421
  • 24
  • 428
  • 436