I am creating an operator mapping that sets the selection register based on
the user's motion. e.g. =*iW to search for the current cWORD and stuff like
that.

I would very much like to be able to set v:searchforward as part of this,
but it's not clear how I can do this. Per :h function-search-undo, any
value assigned to v:searchforward inside of a function is undone when the
function returns. I can work around this most of the time, but not when
doing an operator function using g@.

The mapping is implemented essentially like this:
nmap <silent> =* :<C-U>set operatorfunc=SetSearchPattern<CR>g@

This function sets the search pattern @/ and does a couple of other things.
If I set v:searchforward inside it, the assignment is ignored.

I have other mappings that invoke this function then set v:searchforward in
a separate exec statement:

vmap <silent> z* :call SetSearchFromSelection(visualmode())<CR>:let
v:searchforward = 1<CR>
vmap <silent> z# :call SetSearchFromSelection(visualmode())<CR>:let
v:searchforward = 0<CR>

But I don't know how to do this in conjunction with g@, since what comes
after g@ is interpreted as a motion.

Any suggestions for how I can get around this restriction?

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to