I have the following keybinding in VS code which toggles the position of the cursor between the active document and built-in terminal:
// Toggle between terminal and editor focus { "key": "oem_8", "command": "workbench.action.terminal.focus" }, { "key": "oem_8", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" }
Before i click the shortcut key to move the cursor to the terminal, i first have to save the active file.
I would therefore like to run the file saving command, which after searching on google i believe is :workbench.action.files.save
How would i do this please? i have tried adding the above code snippet at the end of the "command" line but it has not worked.
cheers
You can always mark your 2 most common commands with isBuildCommand and isTestCommand to run them via cmd + shift + b or cmd + shift + t respectively. This answer has some helpful information that might be useful to you as well.
To launch the Define Keybinding widget, press Ctrl+K Ctrl+K. The widget listens for key presses and renders the serialized JSON representation in the text box and below it, the keys that VS Code has detected under your current keyboard layout.
Press Ctrl + Shift + L . This will select all words that match your current selection. It also adds a cursor to each text span matching your current selection. Simply start typing your replacement text and vscode will start replacing all instances of text matching your selection in-editor as you type.
VS Code supports multiple cursors for fast simultaneous edits. You can add secondary cursors (rendered thinner) with Alt+Click. Each cursor operates independently based on the context it sits in. A common way to add more cursors is with Shift+Alt+Down or Shift+Alt+Up that insert cursors below or above.
You would need a macro extension to run multiple commands from one keybinding.
I now use multi-command and there are other macro extensions now.
You can use this keybinding (in your keybindings.json
) with the multi-command
extension - no need for anything in settings.json
:
{ "key": "oem_8", // or whatever keybinding you wish "command": "extension.multiCommand.execute", "args": { "sequence": [ "workbench.action.files.save", "workbench.action.terminal.focus" ] }, "when": "editorTextFocus" // if you want this, you probably do }
If you have more complicated macros you can still build them in your settings.json
if you wish.
Another extension to run multiple commands: Commands
{ "key": "oem_8", "command": "commands.run", "args": [ "workbench.action.files.save", "workbench.action.terminal.focus" ], "when": "editorTextFocus" }
I made this extension. It's great.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With