You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating keyboard shortcuts, it would be nice if you could pass an array of commands (to execute like a macro) that would run the commands in that order.
It would format the file, remove trailing white space then save the file.
Reacted by Aleksej Komarov, Tim Mensch, Mikael Hermansson, mdzor, Sebastian Holmqvist, ねむけ, Mads Moeller, Kostas Rontogiannis, n00dl3, Bill Stewart and 689 more
Reacted by Szymon Marczak, gocs, Github's Fifn2, Zijia Xie, Pafik1337, Damien Flament, Gordon Mohrin, Cosmin, Patrick Lioi, Valentin Dewolf and 54 more
Reacted by Gordon Mohrin, Cosmin, Patrick Lioi, Valentin Dewolf, kgfly, Paul Brussee, Adithya Dsilva, Yegor, Ilya Kaptsevich, ArturoDent and 22 more
Reacted by Ilia Tsvetkov, Soumya Ray, Simon Chan, Kris Kaczor, Bryan Joseph, Paul Ivanov, Marek Krzyżowski, Alex Myers, bunadmitrii, If MacAmeng and 9 more
Reacted by Malcolm, Chris Gaudreau, Simon Chan, Muhammed Albarmavi, Bryan Joseph, itmammoth, Carlos Pérez Alonso, Marek Krzyżowski, David Luzar, allenryb and 19 more
I'm surprised to see so few votes on this issue. I was looking for a way to bring up a terminal and hide the file explorer at the same time, since the integrated terminal doesn't occupy 100% width, and it seems vscode does'nt support multiple commands on a single keybindings yet. :(
I think that @ liangjiancang's suggestion above about the ability to define "key" as an array is also valid. It can save us from copy-pasting for just a minor change.
Just wanted to let you know that we added a built-in command runCommands that can run multiple commands sequentially. This is not first-class support for macros as described in the feature request (this feature request remains open), but this should be quite a handy command, especially given it supports auto-completion/linting for command name and command argument names.
We encourage people to try it out and report issues/suggest improvements in new issues (there is now a GitHub issue label runCommands)
Make sure you're on latest VS Code version - 1.77.
Reacted by Pablo Woolvett, Eugene (dae), Petra Jaros, Bruno Heridet, Gary Gozlan, Nato Boram, sandeep kambham, Andrea Vaccari, depascalis, Chen Chen and 17 more
Reacted by bersbersbers, sandeep kambham, liangjiancang, Skplunkerin, Robin, Niels Bom, Mathias Torp, Christopher Keers and Mikael Medina
Would it be possible to add an argument to the runCommands action to optionally compress the commands into a single Undo action? If that is a big ask I can create a new issue for it.
For example, I am using a "Join Lines without inserting whitespace" key binding like so:
Just wanted to let you know that we added a built-in command runCommands that can run multiple commands sequentially. This is not first-class support for macros as described in the feature request (this feature request remains open), but this should be quite a handy command, especially given it supports auto-completion/linting for command name and command argument names.
We encourage people to try it out and report issues/suggest improvements in new issues (there is now a GitHub issue label runCommands)
Having an issue with workbench.action.open*Settings* commands in runCommands. While it does work, it does throw an error, and prevents further execution of commands from running.
What I'm trying to accomplish is opening the settings.json files on keybind. If I run one of these commands as a root action for the keybind, it does work without issue.
When executing the keybind, I get a VS Code alert:
Converting circular structure to JSON
--> starting at object with constructor 'Y'
| property 'C' -> object with constructor 'Array'
| index 0 -> object with constructor 's'
| ...
| index 1 -> object with constructor 'a'
--- property 'j' closes the circle
*/
As well as the following Output -> Window log:
2024-02-17 08:26:04.812 [error] Method not found: toJSON: CodeExpectedError: Method not found: toJSON
at Object.call (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:42:5090)
at C.s (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:40:5128)
at C.q (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:40:4644)
at $.value (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:40:4051)
at h.y (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:1902)
at h.z (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:1972)
at h.fire (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:2188)
at $.value (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:33:28530)
at h.y (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:1902)
at h.fire (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:2119)
at $.value (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:33:28733)
at h.y (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:1902)
at h.fire (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:35:2119)
at ge (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:33:31158)
at IpcMainImpl.l (C:\Program Files\Microsoft VS Code\resources\app\out\vs\code\electron-main\main.js:42:18908)
at IpcMainImpl.emit (node:events:514:28)
at WebContents.<anonymous> (node:electron/js2c/browser_init:2:79287)
at WebContents.emit (node:events:514:28)
With VS Code Web, I do get a different alert: cyclic object value
With the following log in console:
TypeError: cyclic object value
run commands.contribution.ts:106
handler actions.ts:592
handler commands.ts:98
invokeFunction instantiationService.ts:68
n commandService.ts:95
executeCommand commandService.ts:60
M abstractKeybindingService.ts:372
J abstractKeybindingService.ts:225
W keybindingService.ts:281
d dom.ts:136
a dom.ts:157
W keybindingService.ts:273
x keybindingService.ts:244
ie event.ts:621
x keybindingService.ts:244
j instantiationService.ts:119
t instantiationService.ts:245
s instantiationService.ts:234
r instantiationService.ts:223
q instantiationService.ts:163
m instantiationService.ts:147
get instantiationService.ts:61
ob layout.ts:306
startup workbench.ts:155
invokeFunction instantiationService.ts:68
startup workbench.ts:146
open web.main.ts:131
m web.factory.ts:62
main (index):9
i (index):9
i (index):9
97 (index):9
a (index):9
<anonymous> (index):9
<anonymous> (index):9
notificationsAlerts.ts:40:13
This is without any extensions running (fresh profile). Produced identical results with no extensions and a default profile:
Also, it would be great (and enough to get me by) if there was a way to execute commands and continue regardless of failure? In my example, I may not have a workspace open, so if I opened Application -> Workspace -> User, and no workspace, user would also not open.
Reacted by funky-munky, Vincent Marcus and heartacker
Just wanted to let you know that we added a built-in command runCommands that can run multiple commands sequentially. This is not first-class support for macros as described in the feature request (this feature request remains open), but this should be quite a handy command, especially given it supports auto-completion/linting for command name and command argument names.
We encourage people to try it out and report issues/suggest improvements in new issues (there is now a GitHub issue label runCommands)
I'm confused, was it easier to implement completely new command, rather than check for type of value in existing command, and if it's a string execute it, if it's an array execute each item in the array?
Activity
erichiller commentedon Jul 8, 2016
Abolutely what I was thinking! - another example (mine)
{ "key": "winl+b", "command": [ "workbench.action.tasks.terminate", "workbench.action.tasks.build" ] }geddski commentedon Nov 15, 2016
love this idea
amkgo commentedon Nov 15, 2016
Show any plain text in addition to commands will be great:
For example, using
ctrl+;to move to the end of line and add;and then move to the next line.fbnlsr commentedon Feb 27, 2017
I'm surprised to see so few votes on this issue. I was looking for a way to bring up a terminal and hide the file explorer at the same time, since the integrated terminal doesn't occupy 100% width, and it seems vscode does'nt support multiple commands on a single keybindings yet. :(
Also, #6617 for ref.
faceyspacey commentedon Mar 11, 2017
bstro commentedon Mar 15, 2017
liuhaopen commentedon Mar 17, 2017
ThisIsManta commentedon Mar 18, 2017
Hi guys, I've just found out the extension macros which is exactly I was looking for. Hope this helps you overcome this limitation.
dvf commentedon May 10, 2017
You probably want to allow arguments, for example when using the
typecommand:51 remaining items
vec715 commentedon Mar 7, 2023
a-pav commentedon Mar 8, 2023
I think that @ liangjiancang's suggestion above about the ability to define
"key"as an array is also valid. It can save us from copy-pasting for just a minor change.ulugbekna commentedon Apr 3, 2023
Hello everyone! 👋
VS Code team engineer here 🙂
Just wanted to let you know that we added a built-in command
runCommandsthat can run multiple commands sequentially. This is not first-class support for macros as described in the feature request (this feature request remains open), but this should be quite a handy command, especially given it supports auto-completion/linting for command name and command argument names.We encourage people to try it out and report issues/suggest improvements in new issues (there is now a GitHub issue label
runCommands)You can read more about the command here: https://code.visualstudio.com/docs/getstarted/keybindings#_running-multiple-commands
Make sure you're on latest VS Code version - 1.77.
EugeneDae commentedon Apr 3, 2023
Ulugbek Abdullaev (@ulugbekna) That's a great news, thanks so much!
sandeepkambham08 commentedon Apr 4, 2023
Tested and it works 😉
Thank you 👍
jhuitema commentedon Apr 18, 2023
Thanks, this works great!
Would it be possible to add an argument to the runCommands action to optionally compress the commands into a single Undo action? If that is a big ask I can create a new issue for it.
For example, I am using a "Join Lines without inserting whitespace" key binding like so:
{ "key": "ctrl+shift+j", "command": "runCommands", "args": { "commands": [ "editor.action.joinLines", "deleteRight" ] }, "when": "textInputFocus" }This works great but to undo it you need to Undo twice. Being able to only Undo once would be ideal.
nikivdev commentedon Nov 11, 2023
I just tried it with this:
And it failed. It did not do arrow left after breadcrumbs were focused.
a-pav commentedon Nov 15, 2023
Instead of
cursorLeft, you can usebreadcrumbs.focusPrevious.ATXadam commentedon Feb 17, 2024
Having an issue with
workbench.action.open*Settings*commands inrunCommands. While it does work, it does throw an error, and prevents further execution of commands from running.What I'm trying to accomplish is opening the
settings.jsonfiles on keybind. If I run one of these commands as a root action for the keybind, it does work without issue.Example Keybind:
[ { "key": "ctrl+shift+/", "command": "runCommands", "args": { "commands": [ "workbench.action.openApplicationSettingsJson", "workbench.action.openSettingsJson" ] } } ]When executing the keybind, I get a VS Code alert:
As well as the following Output -> Window log:
With VS Code Web, I do get a different alert:
cyclic object valueWith the following log in console:
This is without any extensions running (fresh profile). Produced identical results with no extensions and a default profile:
Also, it would be great (and enough to get me by) if there was a way to execute commands and continue regardless of failure? In my example, I may not have a workspace open, so if I opened Application -> Workspace -> User, and no workspace, user would also not open.
vanowm commentedon May 2, 2024
I'm confused, was it easier to implement completely new command, rather than check for type of value in existing command, and if it's a string execute it, if it's an array execute each item in the array?