Sublime Forum

[Solved] ST2 Find & Replace Adds Where Nothing There & Ignores Desired

#1

I’m transferring my data from txt files to another program. The new software runs into issues if it sees: ^^. In a 40 document sample alone, that is displayed 100s of times. So I want to insert a space between so it becomes ^ ^.

Let’s hit CTRL + Shift + F to do a find and replace throughout all 40 documents. Suddenly every single empty line now starts with ^ ^ which is garbage for my needs. The original ^^? Completely ignored and unchanged. How can I solve this?

0 Likes

#2

You have the Find and Replace panel set to regex mode. In that mode the search text is assumed to be a regular expression. The ^ character in a regular expression means “match the start of the line”.

As a result, every line matches; the replacement text replaces the match, so what you’ve actually told it to do is “Find the start of every line and insert ^ ^ there”. So on some level, it’s doing exactly what you told it to do. :wink:

You just need to turn the Regex option off in the panel. I use ST3 and not ST2 so I can’t say offhand how to accomplish that in ST2. In ST3 you can press Alt+R to toggle the state back and forth and there is a button in the find panel labeled .* that you can also press. I assume ST2 has something similar.

[edit] I installed ST2 to check, and indeed it operates the same as ST3 does. Make sure the Regex button is not selected by either clicking it or pressing Alt+R (the find panel needs to have the input focus for this to work).

1 Like

#3

This is perfect. Thank you!

1 Like