On Mon, Apr 23, 2012 at 11:06:15AM -0700, smu johnson wrote:
> Hi,
> As the subject suggestions, I can't get the search highlight to work
> from inside a function.
right -- it won't -- take it out (see below)
> If I run it myself using the colon command and typing it in..
> then it works.
> I managed to whittle my .vimrc file down to only the important part.
> In case anyone is curious, I'm trying to simulate the regular
> searching "slash key" to be used to only search and highlight, but
> _not_ jump to the next match. My idea was to just map \s to do it, as
> seen below.
> Anyways, here's what I have, which does not work for me. I'm using
> "VIM - Vi IMproved 7.3, Huge version without GUI." on Ubuntu 9.10.
> Any tips greatly appreciated. Thank you.
> ------- code below -------
> function ChangeSearchRegister ()
> let @/ = "Change"
> set hlsearch
> endfunction
> nnoremap <leader>s :call ChangeSearchRegister()<CR>
I see you've already got something that works, but if you want
alternatives, here's one.
Your ChangeSearchRegister will work as you want if you take the
'set hlsearch' out of the function and put it after your call:
nnoremap <leader>s :call ChangeSearchRegister()<CR>:set hlsearch<CR>
sc
--
You received this message from the "vim_dev" 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