Thursday, April 4, 2013

Re: Yanking text from function

>> You could just call "y" at the beginning of the mapping:
>>
>> vnoremap <silent> y y:call Hook()<cr>
>>
>> This has the added advantage of making the yanked text available in the
>> Hook function in case you need to do something with it.
>>
>> You can do this because, first, you said "noremap" so the second "y"
>> wouldn't trigger the mapping and would just do a yank and, secondly, Vim
>> lets you start a mapped sequence with the keys that actually launched the
>> mapping and falls back to their default behaviour automatically to avoid
>> recursive mappings (so you could do this even if you hadn't specified a
>> noremap).

This worked perfectly, thanks.

--
--
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