How do I record and run multiple find/replace with Sublime Text 2? I tried recording a macro but, as it seems, Sublime won't record find/replace, only text input etc.


Yes, Reg Replace is the way to do it. After installing that package, the way to do it is:

  1. Edit <your Sublime Text Directory>/Packages/RegReplace/reg_replace.sublime-settings (you can access this in ST2 at Preferences > Package Settings > Reg Replace > Settings – Default). Create new entries in the "replacements" object, each one being a single regex find/replace. Note that you have to doubly escape special characters. For example,
    "replacements": {
        "do_something_1": {
        "find": "\\s*\\t\\s*",
        "replace": "\\t",
        "greedy": true,
        "case": false
        "do_something_2": {
        "find": "\\n\\n+",
        "replace": "\\n",
        "greedy": true,
        "case": false
  1. String those individual replacements together into a command for the Command Palette. To do this, edit the file <your Sublime Text Directory>/RegReplace/Default.sublime-commands (Preferences > Package Settings > Reg Replace > Commands – Default). Add something like this:
        "caption": "Reg Replace: My RegEx Macro",
        "command": "reg_replace",
        "args": {
            "replacements": [

Then all you have to do is invoke the command palette by hitting Ctrl+Shift+P and browse to your newly created command.

For reference, on my Windows 7 installation, the Sublime Text directory is at C:/Users//AppData/Roaming/Sublime Text 2/

| improve this answer | |
  • 1
    I did find a way to edit the Default.sublime-commands from the menu. Preferences -> Package Settings -> Reg Replace – Kyle Mar 18 '14 at 15:38
  • Aha. Post updated. – John Alexander May 21 '14 at 21:02
  • @JohnAlexander, Thanks. Having to figure that out on my own - was as likely to happen as getting my brain surgery degree. – mralexgray Dec 21 '15 at 5:53
  • @JohnAlexander if RegReplace get updated automatically by Package Control, will the settings and commands remain? – Edward Apr 12 '17 at 5:07
  • @Edward yes, I believe so. – John Alexander Apr 12 '17 at 15:53

You're right Sublime will not record find/replace.

However from this post on Stackoverflow, it appears you can use RegReplace.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.