\On Aug 9, 9:09 am, yosi izaq <izaq...@gmail.com> wrote:
> On Mon, Aug 9, 2010 at 6:07 PM, ZyX <zyx....@gmail.com> wrote:
> > Ответ на сообщение <<Re: how to display registers 0-9?- concise way & 
> > enhanced
> > #,*>>,
> > присланное в 16:50:14 09 августа 2010, Понедельник,
> > отправитель yosi izaq:
>
> >> Any idea re. how to search for WORD with */# shortcuts?- Can I make a
> >> map like \* \# for that?- Or is there already a common mapping that
> >> does the same?
>
> > There are two ways:
> > 1. Somewhat destructive, but the most simple: yank the word and search for 
> > it:
> >       noremap <special> \* yiW/<C-r>=escape(@", '^$*~[]\')<CR>
> > 2. Custom function, like I use in my transliteration plugin to transliterate
> > current word:
> >            let s:tWregs=[['\(\S*\)', '\(\S\+\|\%$\)'],
> >                         \['\(\s*\)', '\(\s*\)'      ],]
> >            function s:LRmatch(patlist)
> >                let line=getline('.')
> >                let column=col('.')
> >                let match=[]
> >                let i=0
> >                let lpatlist=len(a:patlist)
> >                while i<lpatlist && (match==[] || match[0]=='')
> >                    let 
> > pattern=a:patlist[i][0].'\%'.column.'c'.a:patlist[i][1]
> >                    let match=matchlist(line, pattern)
> >                    let i+=1
> >                endwhile
> >                let lmatch=match[1]
> >                let rmatch=match[2]
> >                return escape(lmatch.rmatch, '^$*~[]\')."\n"
> >            endfunction
> >            " You cannot use script global variables in mappings, but you can
> >            " define a wrapper function
> >            function s:Eval(str)
> >                return eval(a:str)
> >            endfunction
> >            noremap <expr> \* "/".<SID>LRmatch(<SID>Eval('s:tWregs'))
> >            noremap <expr> \# "?".<SID>LRmatch(<SID>Eval('s:tWregs'))
>
> > This is a bit complicated, but it does not do anything with registers 
> > content
> > (except current search register @/, of course)
>
> >> Your answer to first part if helpful, though I didn't understand
> >> what's probably Russian.
>
> > Yes, it is russian:
> > Ответ на сообщение <<...>> -> reply to the message <<TOPIC>>
> > присланное в ...         -> sent on DATE
> > отправитель ...          -> sender NAME
> > Текст сообщения:         -> Message text:
>
> Thanks for the answers.
>
> I chose the first option and tweaked it a bit to work with more spec.
> chars and add \# (duh), ending up with:
> noremap <special> \* yiW/<C-r>=escape(@", '^$*~[]\</>')<CR>
> noremap <special> \# yiW?<C-r>=escape(@", '^$*~[]\</>')<CR>
>
> I think it's useful enough to perhaps post as a tip.

I like selecting the text to search.
The following will search multi-line.
It replaces the vim * search.
Best viewed with mono-spaced font.

" multi line search -- selection literal (vi6.2 ok) :help c_<C-R>
vnoremap * y/\V<C-R><C-R>=substitute(escape(@",'/'),'\n','\
\n','g')<cr><cr>
"""""""""" ||| |    |    |                  |        |    ||    +flag
g=all
"""""""""" ||| |    |    |                  |        |    |+regex=<cr>
"""""""""" ||| |    |    |                  |        |    +escape \
"""""""""" ||| |    |    |                  |        +<cr>
"""""""""" ||| |    |    |                  +contents of register "
"""""""""" ||| |    |    +expression register
"""""""""" ||| |    +contents of register LITERALLY
"""""""""" ||| +contents of register
"""""""""" ||+Very nomagic, only \ is magic
"""""""""" |+search
"""""""""" +yank selected into register

-Bill

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