Sublime Forum

Find and Replace Option in Sublime

#1

Hey there, I was looking into the query about the using of find and replace option in the sublime text. Is it useful in selecting the specific part of the text and then replace the word or we are bound to replace all those words in the code.

0 Likes

#2

You would have to be more specific on what you are asking as I can’t really tell exactly what you are asking.

In general, Sublime can find and replace single instances via Replace and all instances via Replace All.

If you want to step through each instance, you can keep using the the single instance Find which will step through find instances (there are also shortcuts associated to these options).

You control what gets matched via how good your regular expression pattern is. You can select text with context that will filter out things you don’t want to select if your pattern is good enough. Using capture groups can help you replace exactly what you want to replace and avoid replacing what you don’t easier.

You may or may not know most of this already, but I’m being very general as I don’t quite understand specifically what you are asking. If you are in fact new to regular expression, I’d check out https://www.regular-expressions.info/ and read about regular expression features to get a better idea of how they work, and then practice to get a better understanding. You can also ask specific questions if you are having a difficult time understanding.

If I haven’t answered any of your questions, I apologize, but would suggest a more pointed question, maybe with an example?

0 Likes

#3

I kinda like to know that too. I am not sure that my question is the same thing, but lets say I have a bunch of files and want to replace “Foo”. When I do a Find all Files, I get all the occurrences, but I then only can replace all, or click on each found line I think.
Visual Studio Code does this extremely comfortably (hint, maybe steal from them ? :))

0 Likes

#4

On the theme of improving Find/Replace. It would be already very helpful if the find window wasn’t editable. Or if it was, that edits would be affect the actual files and not the Find window, where they are absolutely useless.

0 Likes