Hi,

rameo wrote:
> I created a function to search in columns:
> 
> fun! s:searchcollines()
>   if !exists("g:from_column")
>     let g:from_column = "Search from column:"
>   endif
>   if !exists("g:to_column")
>     let g:to_column = "Search to column:"
>   endif
>   if !exists("g:search_column")
>     let g:search_column = "Search:"
>   endif
>   let f = inputdialog(g:from_column)
>   let g = inputdialog(g:to_column)
>   let s = inputdialog(g:search_column)
>   if f != "" && g != "" && s != ""
>    exe "/\\%>".f."c\\%<".g."c".s
>   endif
> endfun
> 
> ---------------------------
> 
> The search is done but the items found are not highlighted in the
> text.
> hls is on.
> Only after clicking "n" the search items are highlighted.

a search inside a function does not set the @/ register which contains
the last used search pattern. This is documented at

  :help function-search-undo

> How can I make the function highlight the items found?

Instead of executing the search directly as you did with

    if f != "" && g != "" && s != ""
      exe "/\\%>".f."c\\%<".g."c".s
    endif

do it indirectly, i.e., set the last used search pattern and issue the
"n" command:

    if f != "" && g != "" && s != ""
      let @/ =  "\\%>".f."c\\%<".g."c".s
      normal n
    endif

Regards,
Jürgen

-- 
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us.     (Calvin)

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