Visual Studio Code command for “repeat last comman

2020-08-25 05:48发布

问题:

Is there a command which does "repeat last command"? If not, how can I set up such a thing?

Basically what I want is to press some shortcut, and for it to repeat whatever the last command was, so I don't have to find it again in the menu or the ctrl-shift-p box.

回答1:

You can press Ctrl + Shift + P, then Enter it also repeat the lastest command.

Take a look:



回答2:

If you are specifically looking to rerun the last shell command, see Make a keybinding to run previous or last shell commands


Older answer (see above)

So this is a little funky because for the workbench.action.acceptSelectedQuickOpenItem command to work, the command palette must be open. So it will flash open briefly whenever you use the macro keybinding.

Using the macrosRe extension:

"macros": {
    
  "rerunCommand": [
    "workbench.action.showCommands",
    "workbench.action.acceptSelectedQuickOpenItem"
      
  ]
}

I assume you have "workbench.commandPalette.history": 50, set to at least one so that the most recently used command is at the top of the command palette. [I think that setting always puts the last command at the top and selects it.]

And then some keybinding:

{
    "key": "ctrl+;",
    "command": "macros.rerunCommand"
},