Reputation: 8806
Using Visual Studio Code with a TypeScript application, is it possible to rename a variable/function without the affected files to be automatically open in the Editor area?
I'd like my refactorings to be automatically applied, the affected files immediately saved without being automatically open.
I know about the "files.autoSave
" setting and, by using "afterDelay
", I'm indeed able to refactore without the affected files to be automatically open. But I don't want to work with this setting on! Mostly because of linting, the auto saving of files is really annoying.
Any way to perform an immediate refactoring?
Upvotes: 3
Views: 925
Reputation: 1327524
VSCode 1.67 (Apr. 2022) will come with Save automatically when refactoring #47573:
Just like the feature "
Save automatically when Search & Replace
", after refactoring the code (by pressing F2 key or using context menu), the VS Code should save the file(s) automatically.
See PR 146320, available today with VSCode insider release.
files.refactoring.autoSave
Controls if files that were part of a refactoring are saved automatically.
Upvotes: 1
Reputation: 1327524
Maybe the new Rename preview feature of VSCode 1.42 (Q1 2020) would be an acceptable alternative (to opening the files)
Rename preview
VS Code now allows you to preview Rename changes.
When renaming, you can confirm a new name viakb(acceptRenameInputWithPreview)
and the Refactor Preview panel shows.
It displays pending changes in a diff editor and allows you to uncheck/check individual changes.
Once the rename has been applied (or aborted), the diff editor and preview panel close, putting you back in the current editor.
Upvotes: 1
Reputation: 276135
I'd like my refactorings to be automatically applied, the affected files immediately saved without being automatically open.
No its not possible out of the box.
You might do a refactor that you think is small but you end up refactoring 20 files.
You can create your own plugin with its own behaviour. That is what I would do if I was so inclined.
Upvotes: 2