geddski / macros

macros support for VS Code
MIT License
165 stars 36 forks source link

Run different macros per different file type? #42

Closed luni3359 closed 5 years ago

luni3359 commented 5 years ago

I want to run an attribute sorter automatically on save but it breaks my file when running it on a php file, is there any way to make macros run differently per file type?

usernamehw commented 5 years ago

You can use different when conditions when assigning keybindings. Example:

"when": "resourceExtname =~ /(.js)|(.vue)$/" // regex that works in .js or .vue files
"when": "resourceExtname == .ts"// works for .ts files
"when": "editorLangId != typescript"// works for all files except .ts