Ответ на сообщение «Re: how to display registers 0-9?- concise way & enhanced #,*», присланное в 20:09:40 09 августа 2010, Понедельник, отправитель yosi izaq:
> 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, you should remove ``<>'' from escape arguments: not escaping something like ``<html>'' will cause searching for ``<html>'' because 1) there is no special sequence ``<html>'' (this is actual only if someone want to use my function) and 2) there are no special <...> sequence in patterns. But escaping ``<>'' in ``<html>'' will cause searching for word ``html'', not for a tag, see ``:h /\<''. So, ``/'' is the only character I forgot (that is because I just copied escaping function I wrote for matchstr and substitute, they does not treat ``/'' specially). Текст сообщения: > 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
signature.asc
Description: This is a digitally signed message part.