Thanks, that did the trick.
On 06/21/2012 02:44 PM, Gary Johnson wrote:
> On 2012-06-21, richard emberson wrote:
>> I've got a function:
>>
>> function! XXXX()
>> execute '/this'
>> endfunction
>>
>> and when I run it:
>>
>> :call XXXX()
>>
>> my cursor is positioned at the first 'this' but the text
>> is not highlighted (nor is the text of any of the other 'this'
>> highlighted).
>
> The problem is that the search register is saved before a function
> call and restored after, so when your function returns the search
> register no longer contains "this". See ":help
> function-search-undo".
>
> One solution would be
>
> function! XXXX()
> execute '/this'
> return @/
> endfunction
>
> and to use the following instead of ":call XXXX()".
>
> :let @/ = XXXX()
>
> HTH,
> Gary
>
--
Quis custodiet ipsos custodes
--
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
Thursday, June 21, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment