67

In Sublime Text 2, I want search and replace by the TAB character.

I tried replacing with \t char but it's not working.

How can I do it?

slhck
  • 223,558
  • 70
  • 607
  • 592
shingara
  • 773
  • 1
  • 5
  • 6

2 Answers2

103

You can use regular expressions by clicking on this button:

sublime

The regex for a Tab character is \t.

remjih
  • 1,146
  • 1
  • 8
  • 3
  • 11
    Thanks works fine. But you don't need use `/` before and after `\t` is enough – shingara Feb 29 '12 at 15:37
  • Also, it's possible to insert/paste a symbol of an actual tab(ASCII, 9 or U+0009) into "Replace" field. Couldn't paste here because the StackOverflow replaces these in comments section. – Artfaith Oct 12 '20 at 13:27
  • I am trying to search for a pipe `|` and replace with a tab, when i use regular expression search as shown above, the search seems to match every character - maybe i have to escape the pipe? e.g. search for `\|`? – user1063287 Feb 08 '22 at 05:26
  • It works. Thx for you! – dlarchikov Jun 20 '23 at 07:33
1

The accepted answer only give half of the answer to the question

If you want to replace ',' and insert tab: enter image description here

But to replace the tab text with real tab you first have to replace tab text with a different character, and then do the tab insert:

Step1/2) enter image description here

Step2/2) enter image description here

Punnerud
  • 111
  • 4