I'm trying to understand how can I use operator with subsequent motion inside a mapping. For example:
nmap /c c{here we pending for a motion}/<C-r>"<CR>
The map should do the following:
- Activate
c
operator and listen for the next motion; - Eg, I can type here
t,
to change everything before the next comma; - Go to insert mode deleting everything between cursor and the comma;
- Deleted text is automatically searched as a pattern
So to put it simple, after motion text is removed, I'm leaved in insert mode with highlighted occurrences of the deleted text. I would be very grateful if somebody help me to puzzle out this case.
UPDATE
The answers are almost what I want. But! When I press /cw
, type something instead of the word, then press <Esc>
. After I expect to do the same with the next occurrences. But after presing n
(go to next occurrence) and .
(repeat last command) it just prepend last typed text instead of replacing it. The main goal of the mapping is using it with n/N
and .
to repeat. Have I missed something?