tags:

views:

594

answers:

4

How do I find a tab character in emacs?

+14  A: 
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.

Nathaniel Flath
Thanks. Emacs newbies asking this question will want to know that <TAB> means "hit the tab key".
chernevik
+1  A: 

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))
     )
   )
)
Adam Rosenfield
+4  A: 

C-s TAB works for me

justinhj
Why the downvote? I just tested this in various modes in Windows emacs v22.3.1 and linux v 23.0.92.1You don't need the C-q
justinhj
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
All 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
A: 

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)
Alex B