Is there a way of searching for a pattern, but placing the cursor at the end of the pattern rather than at the beginning, when there is a match ?
For example, /my ENTER would place the cursor at the beginning of 'myvariable' ('m').
I find that often, it would be handy if the cursor was placed immediately after the end of the search pattern (here, on the 'v'). Is this possible ?
From :help / you can see the /{pattern}/{offset}<CR> pattern.
From :help offset:
*search-offset* *{offset}*
These commands search for the specified pattern. With "/" and "?" an
additional offset may be given. There are two types of offsets: line offsets
and character offsets.
The offset gives the cursor position relative to the found match:
[num] [num] lines downwards, in column 1
+[num] [num] lines downwards, in column 1
-[num] [num] lines upwards, in column 1
e[+num] [num] characters to the right of the end of the match ## This is the one you want
e[-num] [num] characters to the left of the end of the match
s[+num] [num] characters to the right of the start of the match
s[-num] [num] characters to the left of the start of the match
b[+num] [num] identical to s[+num] above (mnemonic: begin)
b[-num] [num] identical to s[-num] above (mnemonic: begin)
;{pattern} perform another search, see |//;|
If a '-' or '+' is given but [num] is omitted, a count of one will be used.
When including an offset with 'e', the search becomes inclusive (the
character the cursor lands on is included in operations).
So in your case use /my/e+ (or /my/e+1) to land on the v of myvariable.
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