Sublime Forum

Automatically save all files after a global search/replace

#1

When I do a global search/replace in a project, Sublime will automatically open all the files involved, and not save them. I then have to manually save every single file.

Is there a way to have Sublime automatically save all the changes that have been done, and not open the files that where not previously open?

2 Likes

#2

wow, its been 7 years and still no response or fix for this issue. this is the top result from google in 2019 btw.

1 Like

#3

This is probably because everything is working as intended - I don’t think we consider it a good idea to automatically save changes to hundreds of files. It is just too easy to make a modification that isn’t correct, so it really makes sense to review the changes.

4 Likes

#4

@wbond, would it be possible to consider adding this functionality as a user preference as long as you give a warning that this global replace and save will not be reversible.

I’m constantly faced with a use case where I need to do a global search and replace, and it results in 1000s of files being opened in ST, which can take 20 minutes to open and save. I would be a great be able to have ST save the file immediately after Replace without having to open the file as a tab.

0 Likes

#5

You can try CTRL + Shift + P -> File: Save All

1 Like

#6

Yes, I use that shortcut after I waited 10 to 20 minutes for the modified files to open, but my request is to not have the files open at all. I’d like the replace and save to happen in the background so it’s faster and not resource intense.

0 Likes

#7

I am also having the same issue.

Sublime does the replacements very fast, but the amount of memory required to open all files afterwards and the time to save them is too much, and often Sublime will just crash.

This forces to do large replacements from the terminal with sed/awk. But I should be able to use Sublime Text for this (because it is not the speed of the regex engine that is the problem).

There should be an option to replace and immediately save. This would fix the issue.

2 Likes

#8

I would also like to see an option to do a multi-file find/replace without having to manually save the modified documents.

I am used to having this feature in other editors (e.g. bbedit) and yes it should be used with caution (and the warning dialog is not a bad idea), however I always have code under version control so ST is getting in the way here.

I am used to making large multi-file find-replacements in a project and relying on Git to view/manage changes to the file system.

Cheers.

0 Likes