Tuesday, January 28, 2014

Re: map with empty yank

For future reference, I'm quoting here what a guy in stackoverflow suggested:

Note that the semantics of :normal changes when it is contained in a
try...catch loop, or executed through :silent!: Without it, execution
of the command sequence aborts when an error is encountered; the rest
of the sequence is discarded (like in a macro). With it, all commands
execute, even if an error occurs.

Therefore, you can get the desired behavior with

:silent! normal! yi<yi(

Seems a bit cleaner to me than calling :normal twice.

Regards (and thank you again, Christian)
--
Carlos



On Tue, Jan 28, 2014 at 5:41 PM, Christian Brabandt <cblists@256bit.org> wrote:
>
> On Di, 28 Jan 2014, Carlos Pita wrote:
>> thanks for your prompt reply! It's still not clear to me whether
>> yanking a non-existent text object always raises an error or not.
>> cpoptions E seems to apply to y<motion> but it's not clearly stated
>> (at least, I can't find that statement) what happens with y<object>.
>
> I think, there is no such thing as an empty text object. If the text
> object isn't valid, Vim raises an error and this also happens in normal
> mode (you can see, by :set visualbell and see how the terminal flashes
> when doing yi< and the cursor not being within a <> pair.
>
> This errors causes, that your mapping will be aborted.
>
> Best,
> Christian
> --
> I disagree with what you say, but will defend to the death your right to
> tell such LIES!
>
> --
> --
> 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 a topic in the Google Groups "vim_use" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/nBBm61o00pI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
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/groups/opt_out.

No comments:

Post a Comment