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.

Thanks again,
Yosi

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