Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code command for "repeat last command"

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.

like image 713
lonix Avatar asked Aug 23 '18 07:08

lonix


People also ask

How do I rerun code in Visual Studio?

Choose Refresh from the Window menu, or click the Refresh button in the toolbar.

How do you auto complete in VS code?

You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character (such as the dot character (.) in JavaScript).

How do I select next occurrence code in Visual Studio?

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection. Tip: You can also add more cursors with Ctrl+Shift+L, which will add a selection at each occurrence of the current selected text.


3 Answers

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

Take a look:

enter image description here

like image 114
Chau Giang Avatar answered Oct 19 '22 07:10

Chau Giang


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"
}, 
like image 5
Mark Avatar answered Oct 19 '22 08:10

Mark


On Mac simple Ctrl-P repeats the last command on the terminal. Looks like they updated it!

like image 1
Nadav Dafni Avatar answered Oct 19 '22 08:10

Nadav Dafni