Emacs: Search Text in Buffer

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.

emacs isearch 2016-11-02
emacs isearch. Ctrl+s

While in 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.

Note:

  1. Boundary check means, if current word or symbol is “xy”, it will not find “xy2”.
  2. emacs “word” usually means alphanumeric with hyphen. “symbol” means programing language's identifier. Whether LOW LINE _ or HYPHEN-MINUS - is part of “symbol” or “word” depends on current syntax table, which is usually different in different major modes.

Search Current Word Without Boundary Check

Emacs: isearch Current Word

Emacs Isearch Whitespace Regex

Emacs Isearch Whitespace Regex

isearch Keys/Modes

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

I don't recommend using them. If you need regex search, use Alt+x list-matching-lines

[see Emacs: List/Highlight/Delete Matching Lines, Sort Reverse]

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode


Emacs Tutorial

Quick Start

Manage Windows

File

Buffer

Dired

On Current File

Find Replace

Copy/Paste

Unicode

Font

Whitespace

Rectangle Edit

Line Wrap

Shell

View Things

Working with Brackets

Power Editing

Org Mode

HTML

Emacs Efficiency

Misc