On 06/21/12 15:59, 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).
> 
> If I go into search history, the search is there and if I
> execute the historical search, the 'this's all highlight.
> 
> So, my question is: how can I do a search from within a
> function and have the search results highlighted?

To address your immediate issue, I suspect you also need to make
sure that highlight-search is set on

  function! XX()
    /this
    set hls
  endfunction

As a side-note, as you can see in my example, you can directly issue
the search without wrapping it in an exec call.

Alternatively, you might investigate using the :match command
something like

  function XX()
    match Error /this/
  endfunction

where "Error" is the highlighting group you want to use for
colori[zs]ation purposes.

-tim



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

Reply via email to