3

I use this plugin (incsearch.vim) which changes the search function in vim by highlighting the text dynamically while typing the regex after / or ?.

For the plugin to work I had to add these lines in my ~/.vimrc :

map /  <Plug>(incsearch-forward)
map ?  <Plug>(incsearch-backward)

I suppose the result is that whenever I hit / or ?, some functions (incsearch-forward() and insearch-backward()) provided by the plugin are called to take care of the search.

I would like to modify those mappings, so that the plugin's functions are still called but the search begins automatically with \v, the very magic mode is enabled and I don't have to escape (, ), {, + etc.

Without calling the plugin's functions it would give something like this :

map /  /\v
map ?  ?\v

But I don't know how to call the plugin at the same time.

2 Answers 2

5

I would like to modify those mappings, so that the plugin's functions are still called but the search begins automatically with \v, the very magic mode is enabled and I don't have to escape (, ), {, + etc.

You can achieve that by using your previous mappings, by changing some plugin options. This approach avoids cluttering the search line with the \v. From the documentation:

By default 'magic' option, all you can set is 'magic' or 'nomagic',
and in addition, default option has porability problem. see: 'magic'
In contrast to default 'magic' option, |g:incsearch#magic| enable
you to set 'very magic' |\v| and 'very nomagic' |\V| in adition to
'magic' |\m| and 'nomagic' |\M|.
This option doesn't cause porability problems, so you need not worry
about this problem. No other pattern related programs are affected by
this option.
Usage: >
let g:incsearch#magic = '\v' " very magic
let g:incsearch#magic = '\V' " very nomagic
let g:incsearch#magic = '\m' " magic
let g:incsearch#magic = '\M' " nomagic
<
default: ''
0

I think I found. I tried the other way around the first time, sorry.

map /  <Plug>(incsearch-forward)\v
map ?  <Plug>(incsearch-backward)\v

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.