I'm trying to write a vimscript function that will allow me to map a key to select a regex match on the line my cursor is on. This will help with selecting strings for use with ctags.
For example, I have the following text:
0 def hello
1 My::Fancy::Klass.call(args)
2 end
Assuming my cursor is on line 1
, I would like to bind a key to select only the My::Fancy:Klass
text.
I was able to achieve this like so:
nnoremap <leader>] V /\%V\(\(\u\l\+\)\+:\{2}\(\u\l\+\)\+\)\+<cr><esc>
But I would like to do the same with vimscript and am not having any luck.
:h /\v
). Start the pattern with\v
and you no longer need to apply so many backslashes to indicate special meaning. This is the equivalent pattern:\v%V((\u\l+)+:{2}(\u\l+)+)+
.let @/ = '\v%V((\u\l+)+:{2}(\u\l+)+)+'