Benji Fisher wrote:
On Wed, Oct 18, 2006 at 12:28:28PM +0200, Robert Cussons wrote:
Jean-Rene David wrote:
[snip]
"--------------< cut here >---------------------------
" Search for visually selected text {{{
" From an idea by Michael Naumann, Jürgen Krämer.
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "
"
else
execute "normal /" . l:pattern . "
"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
"--------------< cut here >---------------------------
I think the original included raw CR characters in the two :execute
lines. Both are intended to end with "^M" (which is how they appeared
in my copy of Jean-Rene's note). I think your e-mail client broke the
lines, leading to syntax errors.
That may well be, don't know too much about how mozilla -mail works
I try to avoid such problems by not including raw CR, ESC, etc.
characters in my vim scripts. I suggest replacing the two :execute
lines with
execute "normal ?" . l:pattern . "\<CR>"
and
execute "normal /" . l:pattern . "\<CR>"
HTH --Benji Fisher
Everything seems to work fine now, except the searched for items aren't
highlighted like they normally are when I search, is there a simple
reason or am I just asking for too much, sorry I can't sort this out
myself, but I don't understand the function well enough to see a
possilbe reason, the only thing I could think of that might cause it
would be this in my .vimrc
" Clears search highlighting by just hitting a return.
" The <BS> clears the command line.
" (From Zdenek Sekera [EMAIL PROTECTED] on the vim list.)
" I added the final <cr> to restore the standard behaviour of
" <cr> to go to the next line and the mz and `z to return the cursor to its
" precommand position
:nnoremap <CR> mz:nohlsearch<CR>/<BS><CR>`z
However, if this were interfering it would clear the command line as
well and I don't see that so it can't be the cause.
Thanks,
Rob.