Add a hint about interactive replace

This commit is contained in:
az5112 2022-12-04 14:18:03 +01:00
parent c4a5e85cc8
commit d099db4ff5

View File

@ -26,17 +26,26 @@ copy a line:
global replace: global replace:
* vim: :%s/word/replacement<ret> * vim: :%s/word/replacement<ret>
* kak: %sword<ret>creplacement<esc> * kak: %sword<ret>creplacement<esc>,
Explanation: '%' selects the entire buffer, 's' opens a prompt for a Explanation: '%' selects the entire buffer, 's' opens a prompt for a
regex, <ret> validates the regex and replaces the selection with one regex, <ret> validates the regex and replaces the selection with one
per match (hence all occurences of "word" are selected). 'c' deletes per match (hence all occurences of "word" are selected). 'c' deletes
the selection contents and enters insert mode where "replacement" is typed, the selection contents and enters insert mode where "replacement" is
and <esc> goes back to normal mode. typed, and <esc> goes back to normal mode. The final ',' gets rid of
multiple cursors.
Note that the Kakoune version is one key less, and is not a special Note that the Kakoune version is one key less, and is not a special
feature per se, but just a nice way Kakoune features work together. feature per se, but just a nice way Kakoune features work together.
global interactive replace:
* vim: :%s/word/replacement/gc<ret>
and then keep pressing 'y' to accept the change or 'n' to reject.
* kak: /word<ret>creplacement<esc>
and then press 'n' to search for the next occurence and either '.'
to redo the last insert operation (that is replace 'word' with
'replacement') or 'n' to go to the next match.
replace in current curly brace block: replace in current curly brace block:
* vim: viB:s/word/replacement<ret> * vim: viB:s/word/replacement<ret>
* kak: <a-i>Bsword<ret>creplacement<esc> * kak: <a-i>Bsword<ret>creplacement<esc>