Quantcast

Strange behavior of mapping.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Strange behavior of mapping.

Paul Isambert
Hello there,

Given the mapping:

  map <Tab> fXa

where X stands for any character, if X appears on the line, <Tab>
goes to Insert mode after that character, as expected; but if the
character doesn't appear on the line, the cursor shouldn't move but it
should still switch to Insert mode -- and that doesn't happen; it
stays in Normal mode. For instance "map <Tab> fza" stays in Normal
mode on a line with no "z".

Also (I suppose it is related):

  map <Tab> fX<l>a

where <l> denotes one or more "l", encounters the same problem if X
appears on the line but there is less characters than "l"'s in <l>; e.g.:

  map <Tab> fzlla

works well for the first "z" in a line made of "xxxz12z1", but not for
the second (the cursor stays on the "1" in Normal mode)

What am I missing?

Best,
Paul

--
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
|  
Report Content as Inappropriate
star

Re: Strange behavior of mapping.

Christian Brabandt
Hi Paul!

On Di, 10 Jan 2012, Paul Isambert wrote:

> Hello there,
>
> Given the mapping:
>
>   map <Tab> fXa
>
> where X stands for any character, if X appears on the line, <Tab>
> goes to Insert mode after that character, as expected; but if the
> character doesn't appear on the line, the cursor shouldn't move but it
> should still switch to Insert mode -- and that doesn't happen; it
> stays in Normal mode. For instance "map <Tab> fza" stays in Normal
> mode on a line with no "z".
>
> Also (I suppose it is related):
>
>   map <Tab> fX<l>a
>
> where <l> denotes one or more "l", encounters the same problem if X
> appears on the line but there is less characters than "l"'s in <l>; e.g.:
>
>   map <Tab> fzlla
>
> works well for the first "z" in a line made of "xxxz12z1", but not for
> the second (the cursor stays on the "1" in Normal mode)
>
> What am I missing?

When an error occurs, while the mapping is executed, the rest of the
mapping is discarded. This is IIRC, vi-compatible.

regards,
Christian
--
Der allgemeine neuere Vulkanismus ist eigentlich ein kühner
Versuch, die gegenwärtige unbegreifliche Welt an eine vergangene
unbekannte zu knüpfen.
                -- Goethe, Maximen und Reflektionen, Nr. 921

--
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
|  
Report Content as Inappropriate
star

Re: Re: Strange behavior of mapping.

Paul Isambert
Christian Brabandt <[hidden email]> a écrit:

>
> Hi Paul!
>
> On Di, 10 Jan 2012, Paul Isambert wrote:
>
> > Hello there,
> >
> > Given the mapping:
> >
> >   map <Tab> fXa
> >
> > where X stands for any character, if X appears on the line, <Tab>
> > goes to Insert mode after that character, as expected; but if the
> > character doesn't appear on the line, the cursor shouldn't move but it
> > should still switch to Insert mode -- and that doesn't happen; it
> > stays in Normal mode. For instance "map <Tab> fza" stays in Normal
> > mode on a line with no "z".
> >
> > Also (I suppose it is related):
> >
> >   map <Tab> fX<l>a
> >
> > where <l> denotes one or more "l", encounters the same problem if X
> > appears on the line but there is less characters than "l"'s in <l>; e.g.:
> >
> >   map <Tab> fzlla
> >
> > works well for the first "z" in a line made of "xxxz12z1", but not for
> > the second (the cursor stays on the "1" in Normal mode)
> >
> > What am I missing?
>
> When an error occurs, while the mapping is executed, the rest of the
> mapping is discarded. This is IIRC, vi-compatible.

Thank you, Christian. It is indeed mentionned at the end of section 1.6
of map.txt, I'd just never read it (and I suppose I wouldn't have thought
of not finding a character as an error). As far as I'm concerned, I
wouldn't mind if that compatibility were turned off with an option.

Best,
Paul

--
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
|  
Report Content as Inappropriate
star

Re: Strange behavior of mapping.

Jorge Martinez Saez
In reply to this post by Paul Isambert
El 10/01/2012 12:36, Paul Isambert escribió:

> Hello there,
>
> Given the mapping:
>
>    map<Tab>  fXa
>
> where X stands for any character, if X appears on the line,<Tab>
> goes to Insert mode after that character, as expected; but if the
> character doesn't appear on the line, the cursor shouldn't move but it
> should still switch to Insert mode -- and that doesn't happen; it
> stays in Normal mode. For instance "map<Tab>  fza" stays in Normal
> mode on a line with no "z".
If no X appears on the line .... Why vim should do anything?

>
> Also (I suppose it is related):
>
>    map<Tab>  fX<l>a
>
> where<l>  denotes one or more "l", encounters the same problem if X
> appears on the line but there is less characters than "l"'s in<l>; e.g.:
>
>    map<Tab>  fzlla
>
> works well for the first "z" in a line made of "xxxz12z1", but not for
> the second (the cursor stays on the "1" in Normal mode)
>
> What am I missing?
>
> Best,
> Paul
>
Regards

Jorge Martinez Saez

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