Sublime Forum

Macros don't record Find/Replace?


@deathaxe, That is a great script to automate find/replaces.

But what if you just need a Find? I need that awesome result window, with hotlinks to my code.

I have many ColdFusion markup documents that are basically function libraries. If I do a find on this regex, the results are a great table of contents for me to quickly go to the function I want.
RegEx: "<cffunction.*name\s?=\"([^\"]+)\""
And the search range is the current file.

Is it possible to make python create a Results page, or have ST3 do this automatically in some other way?



If you’re using the excellent CFML package, those functions should be in the symbol list, so you can just hit ctrl-r.



I wondered if the plugin I was already using had something like that! Awesome! Thank you!



+1 not recording everything in a Sublime Text macro is a shocking omission. Even Microsoft product macros have been recording everything since the '90’s



Just stumbled on the same disappointment in ST3… (even after all these years)

My use case is to perform ~15 steps to clean up and pre-process a data file,
which I need to do very often… many of the steps involve search and replace by regular expression
So unfortunately a macro can’t help me here.

My guess is that there is something fundamental to the API which limits scope and prevents recording of it…
(does anyone have more details on why? are there any other actions that similarly aren’t recorded?)



Just started using Sublime Text on a Mac having used TextPad on the PC for years
This macro search/replace issue came up pretty quick
All I want to do is remove all blank lines from a text file
e.g. something like: global search/replace on \n\n and replace with \n



I am not certain if this will help, and I do not use it myself, but there is the package Delete Blank Lines.

1 Like


There is also RegReplace. It allows you to define a find and replace (or multiple which you can chain together) and then create a command to execute it. Commands configured to display in the palette, bound to a key map, or even shown in the menu. I use it to set up replaces I commonly do.

1 Like


No dependency workaround

I use find_replace by deathaxe above, because it has a human-readable syntax.

But here is a native-only workaround:

// clean-up-diacritics.sublime-macro
// Replace all incorrectly used Turkish diacritics with Romanian diacritics
  {"command": "select_all", "args": null},
  {"command": "insert_snippet", "args": {"contents": "${SELECTION/(?<1>Ş)|(?<2>ş)|(?<3>Ţ)|(?<4>ţ)/(?{1}Ș:(?{2}ș:(?{3}Ț:ț)))/gm}"}}

via this answer to [pcre] Multiple replacement with just one regex - Stack Overflow

1 Like


Been using sublime since I started programming and now I’m starting to actually become a professional I was 100% sure I was going to purchase a license. Now that I found out that such basic feature is not implemented turns me down a bit, since this is essential for my work. Probably going to rely on emacs for doing things like this for now



I just bought a license today. I was disappointed that I couldn’t properly use find in macro, as I have used this extensively (while on MS windows) with Notebook++.
I plan for Sublime text to be my go to data editor for Linux, but being able to create macho that can find starting point is crucial.

Please make this functionality high priority.

Larz60+ (