Sublime Forum

The problem I encounter today is really horrible and would make the software never be used again

#1

reconstruct the problem:

step 1: “Add Folder to Project”
select a folder as project, let say its name “folder_test” and it has 1,0000 files and every file contains the keyword “foolish”
step 2: replace the keyword
replace the keyword from “foolish” to “fine” in all files (spend a lot of time).


step 3: click “Replace” and confirm

Result:
Sublime creates so many tabs for every file which cause that I can not operate the Sublime again. It would be locked when I reopen the Sublime and try to operate something. I can do nothing and I even cannot close the tabs. I need confirm “Don’t Save” for every tab, closing one tab would cost me a lot of time not mention to 10000 tabs.
The only thing I can do is to drop the Sublime text to trash and download a new Sublime text.

1 Like

How to cancel big operations
#2

this has also been mentioned here: (with some tips for how to clear the session information)

1 Like

#3

Don’t! You can go to %AppData% (should be C:\Users\USERNAME\AppData\Roaming), then go to “Sublime Text 3”, and delete the following:

  • Cache
  • Index
  • Local\Auto Save Session.sublime_session
  • Local\Session.sublime_session
1 Like

#4

Another idea would be to run

[v.run_command(“revert”) for v in window.views()]

in the console to get rid of all the changes on all open files without prompts (assuming you don’t have other changes you don’t want to lose). Then you can close all files from the File menu.

Or if you want to just run “undo” in all the views you could do

[v.run_command(“undo”) for v in window.views()]

2 Likes

#5

It would be nice to see ST implement multifile S&R without opening every file as a tab in a more robust methodology. This is one of my pet annoyances with ST: you need to remember not to do certain things because you know ST isn’t going to like it (big multifile S&R, opening large files all on one line, etc etc).

At very least I’d like to see some internal protection against this kind of thing. A progress bar with cancel, the ability to interrupt any operation. Also I don’t like seeing editors getting slow, ever :wink:

1 Like

#7

One possible solution, which I use all the time

After you hit replace
You can save all open files using Super+Alt+s
You can close all open files using Super+Ctrl+w

I had much success with this approach

2 Likes

#8

I’ve never relied on Sublime’s “Find and Replace in files”. I always either have a visual grep tool or a command line grep tool to do these kind of things.

It’s really a shame the approach Sublime takes with this. This is definitely an area that could use some improvements, but it doesn’t affect me much as I use a dedicated tool for these kinds of replace jobs.

3 Likes

#9

it works. Remove all the stuff in the folder “~/Library/Application Support/Sublime Text 3” for Mac OSX. You are sosososo great.

1 Like

#10

run the snippet in the term2 or something using bash or javascript?

0 Likes

#11

:grin: yes, providing a parameter to determine whether open the R files or not maybe an alternative solution.

0 Likes

#12

in fact, I try to use Grep and Sed(like: sed -i ‘s/old/new/g’ grep pattern -rl) to accomplish those jobs, however, the terminal on the mac seems not work as well as linux.

0 Likes

#13

On mac, I use my own homegrown GUI search and replace tool. Windows has a bunch of similar tools, some that are quite good, but macOS and Linux lack in this area, but they do have grep and sed etc. Mac probably has some, but not anything decent that’s free. I ended up just writing a cross platform one and run it on all my systems.

1 Like

#14

You can run them in the sublime window console (the python interpreter with access to the sublime API that you get when you press Ctrl+` or by going to the menu view->Show Console). The snippets are python using the sublime API to traverse all the open views (opens tabs in that window) and executing the command for that view (equivalent of running File -> Revert File, or Edit -> Undo, respectively for the view).

0 Likes

#15

In general it works just as well, but it’s different because it’s BSD based. You tend to run into that with some tools like sed, where you can’t always use exactly what you’re used to on Linux or find on StackOverflow.

0 Likes