how to display registers 0-9?- concise way & enhanced #,*

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

how to display registers 0-9?- concise way & enhanced #,*

yosi izaq
Hi,

As per subject. Yes :reg 0123456789 will do but aside from map is
there a more concise way?

like:
:reg seq(0,9)

I know it doesn't work, is there an equivalent that does?
note, :regi could do but it's overkill and takes more time...

Oh, and is there a WORD search equivalent to #,* (that search word) w/
o mapping?- if not, is there a commonly used map?

TIA,
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 | Threaded
Open this post in threaded view
|

Re: how to display registers 0-9?- concise way & enhanced #,*

Nikolay Aleksandrovich Pavlov
Ответ на сообщение «how to display registers 0-9?- concise way & enhanced #,*»,
присланное в 16:54:56 05 августа 2010, Четверг,
отправитель Yosi Izaq:

    execute 'registers '.join(range(0, 9))
? ``execute'' may be truncated to ``exe'', ``registers'' to ``reg',' other part
cannot by truncated, but ``j<tab>'' gives ``join('' and ``r<tab>'' gives
``range(''.

Текст сообщения:

> Hi,
>
> As per subject. Yes :reg 0123456789 will do but aside from map is
> there a more concise way?
>
> like:
> :reg seq(0,9)
>
> I know it doesn't work, is there an equivalent that does?
> note, :regi could do but it's overkill and takes more time...
>
> Oh, and is there a WORD search equivalent to #,* (that search word) w/
> o mapping?- if not, is there a commonly used map?
>
> TIA,
> yosi

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how to display registers 0-9?- concise way & enhanced #,*

yosi izaq
On Thu, Aug 5, 2010 at 8:44 PM, ZyX <[hidden email]> wrote:

> Ответ на сообщение <<how to display registers 0-9?- concise way & enhanced #,*>>,
> присланное в 16:54:56 05 августа 2010, Четверг,
> отправитель Yosi Izaq:
>
>    execute 'registers '.join(range(0, 9))
> ? ``execute'' may be truncated to ``exe'', ``registers'' to ``reg',' other part
> cannot by truncated, but ``j<tab>'' gives ``join('' and ``r<tab>'' gives
> ``range(''.
>
> Текст сообщения:
>> Hi,
>>

Hi ZyX,

Your answer to first part if helpful, though I didn't understand
what's probably Russian.
Thanks!

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?

Thanks,
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 | Threaded
Open this post in threaded view
|

Re: how to display registers 0-9?- concise way & enhanced #,*

Nikolay Aleksandrovich Pavlov
Ответ на сообщение «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:

Текст сообщения:

> On Thu, Aug 5, 2010 at 8:44 PM, ZyX <[hidden email]> wrote:
> > Ответ на сообщение <<how to display registers 0-9?- concise way &
> > enhanced #,*>>, присланное в 16:54:56 05 августа 2010, Четверг,
> >
> > отправитель Yosi Izaq:
> >    execute 'registers '.join(range(0, 9))
> >
> > ? ``execute'' may be truncated to ``exe'', ``registers'' to ``reg','
> > other part cannot by truncated, but ``j<tab>'' gives ``join('' and
> > ``r<tab>'' gives ``range(''.
> >
> > Текст сообщения:
> >> Hi,
>
> Hi ZyX,
>
> Your answer to first part if helpful, though I didn't understand
> what's probably Russian.
> Thanks!
>
> 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?
>
> Thanks,
> Yosi

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how to display registers 0-9?- concise way & enhanced #,*

yosi izaq
On Mon, Aug 9, 2010 at 6:07 PM, ZyX <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: how to display registers 0-9?- concise way & enhanced #,*

Bee-9
\On Aug 9, 9:09 am, yosi izaq <[hidden email]> wrote:

> On Mon, Aug 9, 2010 at 6:07 PM, ZyX <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: how to display registers 0-9?- concise way & enhanced #,*

Nikolay Aleksandrovich Pavlov
In reply to this post by yosi izaq
Ответ на сообщение «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 <[hidden email]> 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 (205 bytes) Download Attachment