Sublime Forum

Find/Replace: replace parts from find pattern, and multi cur

#1

How can I do a find replace using parts of my regex match? In vim this would look like this: s/task\d/&_id/g. This would result in ‘task1’ and ‘task2’ being replaced by ‘task1_id’ and ‘task2_id’.
In this instance I could just use multi-cursor… but how do I invoke multi-cursor on my find matches?

A more advanced case would be s/task(\d)/task_item_\1_id/g would result in task1 being replace by task_item_1_id. Is this possible in ST2?

0 Likes

#2

First case:

Find what: task\d
Replace with: $0_id

Second case:

Find what: task(\d)
Replace with: task_item_$1_id

Martin

0 Likes

#3

Perfect thanks.

0 Likes