Emacs: Search Text in Current File

By Xah Lee. Date: . Last updated: .

This page shows you how to use search and highlight features in emacs.

The most useful one is “isearch”.

Alt+x isearch-forwardCtrl+s
Interactive search text in current buffer.

While in isearch prompt:

  • Ctrl+s → Jump to next occurrence
  • Ctrl+r → Jump to previous occurrence.
  • Ctrl+g → Exit and place cursor at original position.
  • Enter → Exit and place cursor at current position.
emacs isearch 2021-07-20
emacs isearch

How to make case sensitive in isearch?

By default, search is not case sensitive unless your search string contains Capital Letter.

While in isearch, press Alt+s c to toggle search case-sensitivity.

Or, Alt+x toggle-case-fold-search before isearch. Remember to toggle it back.

Search Word Under Cursor

While in isearch, press Ctrl+w to select more strings to the right of cursor.

The following commands do isearch but uses the word the cursor is on, saves you typing.

Alt+x isearch-forward-symbol-at-pointAlt+s .
Search the “symbol” under cursor, with boundary check.
Alt+x isearch-forward-wordAlt+s w
Search the word under cursor, with boundary check.
Alt+x isearch-forward-symbolAlt+s _
Same as isearch but with boundary check.

Note:

isearch Keys/Modes

isearch has many complex features. You can read about them by:

I don't recommend using them because they are very complex. If you need regex search, use Alt+x list-matching-lines [see Emacs: List/Delete Matching Lines]

Emacs Find Replace


Emacs Tutorial

Quick Start

Font

Split Window

File

Buffer

Copy/Paste

Find Replace

Unicode

Whitespace

Rectangle Edit

Line Wrap

Shell

View Special File

Editing Brackets

Org Mode

HTML

Emacs Efficiency

Misc