On Wednesday, July 25, 2012 11:18:10 PM UTC-5, Bee wrote:
> I created a function that given a string will modify it to make a
> search pattern.
>
> fu! Find(str)
> " build search pattern based on str
> let @/ = pattern
> try
> execute "normal /" . pattern . "\<cr>"
> catch
> endtry
> endf
>
> It works very well.
>
> When I use the 'normal' find, I have it set to highlight all found.
>
> When I use the function the pattern is found but not highlighted. If
> ':set hls' is added IN the function the found text is still NOT
> highlighted. When 'n' is used to find the next occurrence... THEN the
> text is highlighted.
>
> I can use a command like this to turn on highlighting, then call the
> function and that works.
>
> set hlsearch | call Find("hello")
>
> Is there a way to turn on highlighting within the function?
>
> Bill
On Wednesday, July 25, 2012 11:18:10 PM UTC-5, Bee wrote:
> I created a function that given a string will modify it to make a
> search pattern.
>
> fu! Find(str)
> " build search pattern based on str
> let @/ = pattern
> try
> execute "normal /" . pattern . "\<cr>"
> catch
> endtry
> endf
>
> It works very well.
>
> When I use the 'normal' find, I have it set to highlight all found.
>
> When I use the function the pattern is found but not highlighted. If
> ':set hls' is added IN the function the found text is still NOT
> highlighted. When 'n' is used to find the next occurrence... THEN the
> text is highlighted.
>
> I can use a command like this to turn on highlighting, then call the
> function and that works.
>
> set hlsearch | call Find("hello")
>
> Is there a way to turn on highlighting within the function?
>
> Bill
Change your function call to (untested):
:set hlsearch | call Find("hello") | let @/=@/
But it looks like your function does nothing but search for the string passed
in. What's it's purpose? Vim provides the search() function to do the same
thing.
--
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