Reputation: 4000
How do I find a tab character in emacs?
Upvotes: 68
Views: 23952
Reputation: 3278
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.
Upvotes: 3
Reputation: 24936
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)
Upvotes: 9
Reputation: 400274
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))
)
)
)
Upvotes: 8
Reputation: 16015
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.
Upvotes: 85