In vim/gvim I would like to be able to move to the front and end of the current search lookup. Is this possible?
For example, with this file:
A dog and a cat
A hat and a bat
I would like to be able to perform a search, for example /dog\sand and then be able to move from the beginning of the ‘dog and’ expression to the end and back so that my cursor starts on column 3, under the letter ‘d’ of the word ‘dog’ and then moves to column 9 under the letter ‘d’ or the word ‘and’.
The reason I want to be able to do this is so that I can search for an expression and then use the change command, c, combined with a movement command to replace that particular search expression. I don’t want to use substitue and replace here, I want to perform this operation using the change command and a movement key.
You can change to the end of the match with
c//e<CR>. And//<CR>will take you to the beginning of the next match. You could probably work out some kind of bindings for those that make sense. For instance I just tried the following, and it seems to work nicely:So that you can say
cmfor change match. I’m not sure what I would map//<CR>to, though. I tried mapping it ton, and it seemed to work fine. Don’t know if that would be a problem for you.