Searching and replacing in emacs

Day two of my serie about emacs, about searching and replacing.

Function name : isearch-forward
Typical Key sequence : C-s
How to get help : C-h f isearch-forward
Usage : isearch-forward let you type a string to be searched incrementally in the current buffer, successive following C-s will jump to the next match.

Function name : isearch-forward-regexp
Typical Key sequence : C-M-s or C-u C-s
How to get help : C-h f isearch-forward-regexp
Usage : isearch-forward-regexp let you type a regexp to be searched incrementally in the current buffer, successive following C-s will jump to the next match.

Function name : query-replace
Typical Key sequence : M-%
How to get help : C-h f query-replace
Usage : M-% search RET replace RET
Then, for each term found, query-replace will ask you what to do : space or y to replace, delete or n to skip, RET or q to exit, ! for ‘yes for all’, ? to get help about how to enter recursive edit / delete match and recursive edit / edit replacement string / …

Then you should read about replace-string, replace-regexp, occur, list-matching-lines, multi-occur, multi-occur-in-matching-buffers, how-many, flush-lines, and keep-lines.

Case sensitivity :
A search is by defaut case insensitive, but if you input an upper case letter, it become case sensitive. M-c during a search toggle the case sensitivity.

Configuration variables :
You may consult the documentation about those variable typing :
C-h v variable
or
M-x apropos-variable RET case-fold-search RET

  • case-fold-search (Non-nil if searches and matches should ignore case.)
  • default-case-fold-search (Default value of `case-fold-search’)
  • tags-case-fold-search (Whether tags operations should be case-sensitive.)
This entry was posted in emacs. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>