I have a string that has lots of forward slashes. I need to search it
and delete it (e.g. unix path name). I could use a backslash for
everything forward slash and find it in vim. Is there a way I need not
do that? For now, I use 'grep -n' to get the line number and then delete
it. I don't actually type the string, I just use cut-and-paste!
You could use an other separator, let's say : instead of /
BTW, I have the following in my vimrc file, which may help you, if you
already have one occurrence, since you can search for the selection
easily by the following mappings:
" Search in Visual and Selection modes with '*' and '#'
function MakeSearchString(str)
return substitute(escape(@", '\\/.*$^~[]'), '\n', '\\n', 'g')
endfunction
function! <SID>VisualSearch(direction)
if a:direction == '#'
let l:rhs = "y?"
else
let l:rhs = "y/"
endif
let l:rhs = l:rhs . "\<C-R>=MakeSearchString(@\")\<CR>\<CR>gV"
return l:rhs
endfunction
vnoremap <expr> * <SID>VisualSearch('*')
vnoremap <expr> # <SID>VisualSearch('#')
" Search for word under cursor
inoremap <F3> <C-O>*
nnoremap <F3> *
onoremap <F3> <C-C>*
" Search backwards for word under cursor
inoremap <S-F3> <C-O>#
nnoremap <S-F3> #
onoremap <S-F3> <C-C>#
" Search for/Substitution of selection
vnoremap <F3> y/<C-R>=MakeSearchString(@")<CR>
vnoremap <S-F3> y?<C-R>=MakeSearchString(@")<CR>
vnoremap <M-F3> y:%s/<C-R>=MakeSearchString(@")<CR>/
Best regards,
Georg
___________________________________________________________
Yahoo! Messenger - with free PC-PC calling and photo sharing. http://uk.messenger.yahoo.com