Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# RegReplace

## 3.10.0

- **NEW**: Add `reg_replace_chain` command.

## 3.9.0

- **NEW**: Changes to support Python 3.13 on ST 4201+.
Expand Down
19 changes: 19 additions & 0 deletions docs/src/markdown/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,25 @@ You can also bind a replacement command to a keyboard shortcut:
}
```

As noted in the arguments above, `multi_pass` applies to a chain of replacements, but each replacement in a chain
cannot be controlled individually. In some cases, it may be desired that some patterns are applied multiple times, while
others are not. If this is the case, you can chain multiple replace commands together using the `reg_replace_chain`
command. Then each command can can be configured separately.


```js
{
"caption": "Reg Replace: Chained Command"
"command": "reg_replace_chain",
"args": {
"commands": [
{"command": "reg_replace", "replacements": ["replace_command_1"]},
{"command": "reg_replace", "replacements": ["replace_command_2"], "multi_pass": true}
]
}
}
```

## Selection Inputs

/// warning | Experimental
Expand Down
11 changes: 11 additions & 0 deletions rr_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ def on_pre_save(self, view):
self.apply(view, self.unfolds, action="unfold")


class RegReplaceChain(sublime_plugin.TextCommand):
"""RegReplace chain command."""

def run(self, edit, commands):
"""Chain multiple commands."""

for command in commands:
cmd = command.pop('command')
self.view.run_command(cmd, command)


class RegReplaceCommand(sublime_plugin.TextCommand):
"""RegReplace command."""

Expand Down
Loading