How do I find a tab character in emacs?
5 Answers
C-s C-q <TAB>
C-s starts an incremental search, and then C-q runs quoted-insert, which inserts the next character you type literally. Then, pressing the TAB key will insert a tab character. Continue hitting C-s to go to the next tab character.

- 15,477
- 19
- 69
- 94
-
8Thanks. Emacs newbies asking this question will want to know that
means "hit the tab key". – chernevik Jun 01 '09 at 17:35
Just do the combination of keys as follows:
C-s TAB

- 137,073
- 23
- 153
- 219

- 11,147
- 11
- 58
- 104
-
4Why the downvote? I just tested this in various modes in Windows emacs v22.3.1 and linux v 23.0.92.1 You don't need the C-q – justinhj Jun 01 '09 at 17:18
-
I'm speculating (and didn't downvote), but maybe because people didn't think it would work, or that they figured that if chernevik were having problems, then the unquoted TAB wasn't working for him? – Blair Conrad Jun 01 '09 at 17:38
-
5All of C-s TAB, C-s C-q TAB, and C-s C-q C-i work for me. Maybe somebody could explain when/why C-s TAB doesn't work? – Chris Conway Jun 01 '09 at 18:42
-
Downvotes may also happen because it only answers the specific problem, without helping the asker with the general understanding of what
does differently in search mode and typing mode. (It works for me, even though I would have suspected it not to.) – Nikana Reklawyks Jul 23 '14 at 23:13
I use whitespace mode to highlight all tabs with the following in my .emacs file:
;whitespace http://www.emacswiki.org/emacs/WhiteSpace
(require 'whitespace)
(setq whitespace-style '(tabs tab-mark)) ;turns on white space mode only for tabs
(global-whitespace-mode 1)

- 24,678
- 14
- 64
- 87
Hit C-s
to start an incremental search, then type C-q C-i
to search for a literal tab character.
If you want to visualize tab characters, you can add the following to your ~/.emacs
file to colorize tabs:
; Draw tabs with the same color as trailing whitespace
(add-hook 'font-lock-mode-hook
'(lambda ()
(font-lock-add-keywords
nil
'(("\t" 0 'trailing-whitespace prepend))
)
)
)

- 390,455
- 97
- 512
- 589
In some versions of emacs, you can simply do
C-s <TAB>
where <TAB>
is a stroke of the tab key.
If that doesn't work, C-i
is a synonym for <TAB>
, so to search for tabs, do
C-s C-i
In addition, C-q <TAB>
means the same thing as C-i
, so you could also search for tabs with
C-s C-q <TAB>
Furthermore, C-i
or C-q <TAB>
can be used to insert a tab character in other situations where the tab key does not. For example, if you have emacs set to auto-expand tabs into spaces, you can still use C-i
to insert the tab character while editing.

- 3,164
- 4
- 28
- 40