As stated in the title, I want to search and edit (including replace) certain strings in a selected part of a buffer, not the entire buffer!!!, how can I do it? Are there any built-in keystrokes?
Vanilla Emacs has
query-replaceand related commands, that stop successively at each match for your search pattern and ask whether you want to replace it, then move on to the next match. When the region is active then these commands limit searching to the region.
You can always narrow the buffer (
C-x n n) to the region, and then use ordinary Isearch.
If you use Isearch+ then you can also replace any given matches, on demand. Unlike
query-replacecommands, which necessarily ask you about replacing each search hit in turn (or replacing all subsequent hits at once), on-demand means that when you are incrementally searching you can replace the current search hit by hitting a key.
I would think that a simple region based vi[m] search and replace should do the trick. Eg to indent a region with 2 spaces
- Mark start of region using marker k - mk
- Move a couple of lines down for the desired range
- Do the vim replace for the region - :'k,.g/^/s// /
but that results in 'Replaced 0 occurences'. This works 100% in viper mode.