Monday, November 17, 2014

Re: :%s//\=@o/gce ignores c flag in key mapping

On Monday, November 17, 2014 5:27:47 AM UTC-6, Tim Chase wrote:
> On 2014-11-15 13:59, porphyry5 wrote:
> > On Friday, November 14, 2014 4:02:55 PM UTC-8, porphyry5 wrote:
> > > In a key mapping I use the command ':%s//\=@o/gce'.
> > >
> > > The command executes as expected except that it behaves as if the
> > > c flag were not set.  Is this flag unavailable in a key mapping,
> > > or is there some other option that needs to be set for it to
> > > work.  It works as expected at the command line.
> >
> > This is the mapping concerned:
> > "map ,, /@@<CR>"myWcwqq<Esc>h"oywxx"nywma:let
> > @/=@m<CR>:%s//\=@n/ge<CR>:let @/=@n<CR>:%s//\=@o/gce<CR>`ay2h`a:if
> > @" != 'qq'<CR>:norm "Zyw<CR>:en<CR><CR>
>
> Ah, I believe the problem is triggered because the atoms after the
> ":%s//\=@o/gce<CR>" are interpreted as answers to the y/n/a/q/l/^E/^Y
> prompt. The back-tick is ignored and the "a" (the subsequent atom)
> is interpreted as "a"ll the remaining matches.
>
> For this to work (actually prompting the user), the
> ":%s//\=@o/gce<cr>" has to be the last item in your mapping, leaving
> the :s command in the user-prompting state.
>

If this is the cause, it's probably cleaner to wrap everything in a function with one command per line, and call the function from the mapping. Then there are fewer ways for it to go awry.

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: