cnoremap + getcmdtype()

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

cnoremap + getcmdtype()

iler.ml
cnoremap <expr><enter> (getcmdtype()=='/' ? "\n:redraw" : "\n")

I am intercepring the <enter> in the /pattern search.

When search is found, it works. E.g., type /.<enter>, and you see :redraw
as a sign that mapping worked.

But when search was not found, this mapping does not work.
Why ? Type /xyzxyz<enter>, and :redraw does not appear. Why ?

Yakov
Reply | Threaded
Open this post in threaded view
|

Re: cnoremap + getcmdtype()

Bram Moolenaar

Yakov Lerner wrote:

> cnoremap <expr><enter> (getcmdtype()=='/' ? "\n:redraw" : "\n")
>
> I am intercepring the <enter> in the /pattern search.
>
> When search is found, it works. E.g., type /.<enter>, and you see :redraw
> as a sign that mapping worked.
>
> But when search was not found, this mapping does not work.
> Why ? Type /xyzxyz<enter>, and :redraw does not appear. Why ?

The "\n" that executes the search will result in an error.  This error
will clear the typeahead, thus ":redraw" is gone.

--
From "know your smileys":
 :-H Is missing teeth

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
Reply | Threaded
Open this post in threaded view
|

Re: cnoremap + getcmdtype()

iler.ml
On 10/22/06, Bram Moolenaar <[hidden email]> wrote:

>
> Yakov Lerner wrote:
>
> > cnoremap <expr><enter> (getcmdtype()=='/' ? "\n:redraw" : "\n")
> >
> > I am intercepring the <enter> in the /pattern search.
> >
> > When search is found, it works. E.g., type /.<enter>, and you see :redraw
> > as a sign that mapping worked.
> >
> > But when search was not found, this mapping does not work.
> > Why ? Type /xyzxyz<enter>, and :redraw does not appear. Why ?
>
> The "\n" that executes the search will result in an error.  This error
> will clear the typeahead, thus ":redraw" is gone.

Thanks
Yakov