I have a large amount of tab-indented (outlined) text that is missing a leading bullet character:
some point
a sub-point
I want to replace each tab by 2 spaces, and add a hyphen in front. This is the target format I need:
- some point
- a sub-point
Find:
I can use the regex \t+\S
to find "any number of tabs, followed by any non-whitespace". This works just fine, and the "find" function highlights the start of every line, up to and including the first non-tab character.
Replace:
How can I use regex to specify "replace every tab with 2 spaces, followed by one hyphen and one space, followed by the original non-tab character"? Specifically:
- How do I specify the replacement to happen "as many times as there were matches in the find"? (So three tabs would become six spaces, etc.)
- How do I specify the literal "one hyphen then one space"?
- How do I specify "keep the non-tab character unchanged"?
My google-fu has led me to the concept of \1
but I don't see how I can use that. My trial-and-error testing only produced errors.
Update:
I discovered a thing about \1
: I must use parentheses in my find string: (\t+)(\S)
and then use that in the replace part: \1- \2
. This helps me to solve item #2 and #3 above, but I am still at a loss about #1!
Up-Update:
Duh - #1 can be a simple non-regex find/replace action as long as there are no tab characters elsewhere in the text. That's something I need to investigate now!
I am trying with Ubuntu's Gedit but I could also use Notepad++ or Sublime if you have editor-specific suggestions.