Reputation: 6503
Is it possible to automatically save all changed files before build? It's a bit tedious to press Ctrl+s and then Ctrl+Shift+b all the time.
Upvotes: 26
Views: 21965
Reputation: 779
This feature seems to have been implemented now:
Goto: File > Preferences > Settings
In "Search Settings" box at top, enter "Save".
Multiple matches will be listed.
Scroll down to: Task: Save Before Run and select: Always save all editors before running
Before leaving, take a moment to review some of the other language-specific options to see if any of them is of interest.
Upvotes: 5
Reputation: 14988
If you don't need to build but rather run the file, then you can adjust the Code Runner extension settings by adjusting your user settings. Settings can be accessed in file > preferences > settings
(or with Ctrl+comma.)
To save the current file before running add the line below to your User Settings:
"code-runner.saveFileBeforeRun": true,
or to save all files before running, add this line:
"code-runner.saveAllFilesBeforeRun": true,
I also added this shortcut key(keybinding) to file > preferences > keyboard shortcuts > keybindings.json
{
"key": "ctrl+enter",
"command": "code-runner.run"
},
Now I can just hit Ctrl+Enter and all the magic happens.
Upvotes: 17
Reputation: 6503
Turns out there is an open feature request for this - https://github.com/Microsoft/vscode/issues/21342
The reverse thing (build on save) can be done, for example, with extension "Trigger Task on Save" (https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.triggertaskonsave)
Upvotes: 3
Reputation: 44447
Setting files.autoSave
to afterDelay
is probably your best alternative. You can combine it with decreasing autoSaveDelay
so that files are autosaved quickly without you having to do anything.
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 100,
Upvotes: 1