I use emacs for viewing and editing code and other text files. I wanted to know if there is a way to search forward or backward for text which is marked in the current buffer. Similar to what I can do in notepad or wordpad. As in can I mark some text in the buffer and do a C-s or C-r and be able to search with the marked text without actually typing in the whole search text?
Thank you,
Rohit
Simple Searches Emacs also offers a simple, or nonincremental, search. To use a more straightforward search, type C-s RETURN or select Search from the Search menu. Type the search string, press RETURN, and Emacs begins the search. Simply press C-s again to repeat the search.
To search backwards, use C-r ( isearch-backward ) instead of C-s to start the search. A backward search finds matches that end before the starting point, just as a forward search finds matches that begin after it.
@Alex nails it.
Another option I use quite often is C-s C-w
to search for the word after the current mark. Hitting C-w
repeatedly increases the search with additional words (e.g., C-s C-w C-w C-w
searches for the 3 words after the current mark).
Similarly, C-s M-s C-e
searches for the rest of the line after the current mark and C-s C-M-y
searches for the character after the mark. These are both repeatable in the same way (the former by somewhat-awkwardly repeating M-s C-e
after C-s
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With