I cannot realise a :map why ??

57 views
Skip to first unread message

aubertin.sylvain

unread,
Jul 21, 2015, 4:02:15 AM7/21/15
to vim...@googlegroups.com
For instance I should like to make F9 stand for papa
Following VIM Manual (by Moolenaar) I type :
:map <F9> ipapa<Esc> (5 characters for <Esc> and 4 characters for <F5> )
But it doesn't work. Instead of « papa «  , it returns <F9>
Something is wrong, but where ?? Thanks for your reply.

Shlomi Fish

unread,
Jul 21, 2015, 5:23:28 AM7/21/15
to aubertin.sylvain, vim...@googlegroups.com
Hi Aubertin,
Your mapping (“:map <F9> ipapa<Esc>”) works fine for me after I put it at the
end of my ~/.vimrc file. So we need more details:

* What is your OS / distro / version .

* Which version of vim / gvim / macvim / etc. are you using?

* Other possible details.

Regards,

Shlomi Fish


--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Humanity - Parody of Modern Life - http://shlom.in/humanity

There are at least 137 Larry Walls in the U.S., but only one that matters.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

John Little

unread,
Jul 21, 2015, 6:00:38 AM7/21/15
to vim...@googlegroups.com
On Tuesday, July 21, 2015 at 8:02:15 PM UTC+12, aubertin.sylvain wrote:
> Following VIM Manual (by Moolenaar) I type :
> :map <F9> ipapa<Esc> (5 characters for <Esc> and 4 characters for <F5> )
> But it doesn't work. Instead of « papa «  , it returns <F9>
> Something is wrong, but where ??

That's a "normal mode" mapping, you appear to be want it to work in insert mode. Try
:imap <F9> papa

If you are shaky on modes, you could start at :help 02.2, "The Vim editor is a modal editor". If you understand modes, check out :help map-modes.

Regards, John Little

Erik Christiansen

unread,
Jul 21, 2015, 6:25:30 AM7/21/15
to vim...@googlegroups.com
On 21.07.15 01:02, aubertin.sylvain wrote:
> For instance I should like to make F9 stand for papa
> Following VIM Manual (by Moolenaar) I type :
> :map <F9> ipapa<Esc> (5 characters for <Esc> and 4 characters for <F5> )

That works for me, when typed on Vim's command line, omitting your
bracketed comment. In .vimrc there'd be no leading ':'.

Does a ":map" show that your new mapping has been accepted?
If so, I'd try another key - not a function key.
If the mapping was not accepted, and there was no error message, then I
think there would be a raising of eyebrows, and some action.

I do notice at :h :map-special-keys
"The <> form cannot be used when 'cpoptions' includes the '<' flag."
so what does ":set cpoptions ?" show?

Having "paste" set would inhibit the mapping in insert mode, but the
mapping makes clear that you intend to use it in normal mode.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Presumably your tests were conducted in normal mode, but a leading <Esc>
covers mode forgetfulness, and a "noremap" is good form:

:noremap <F9> <Esc>ipapa<Esc>

If we're not there yet, maybe try another case, to gather information:

:noremap <F1> :set nornu<CR> " Clear relative line numbering.

:set rnu " Set relative line numbering.

Then press <F1>. The numbers should go away again.

Even if your <F9> had been mapped to something else, the new mapping
would replace that.

As an aside, interestingly, I read:

>>> *map-comments*
It is not possible to put a comment after these commands, because the '"'
character is considered to be part of the {lhs} or {rhs}.
<<<

And yet I have no problem with this in my .vimrc:

" For vimdiff:
noremap <F10> :diffput<CR>]c " Copy first -> second file, next change.
noremap <F9> :diffget<CR>]c " Copy first <- second file, next change.

Erik

aubertin.sylvain

unread,
Jul 21, 2015, 9:43:52 AM7/21/15
to vim...@googlegroups.com
Many Thanks to Shlomi Fish.
My vim version: 7.4.52
My OS : xubuntu 14.04.1
My PC hp Mini 110 1100

Nikolay Pavlov

unread,
Jul 21, 2015, 1:58:57 PM7/21/15
to vim...@googlegroups.com
2015-07-21 13:35 GMT+03:00 Erik Christiansen <dva...@internode.on.net>:
> On 21.07.15 01:02, aubertin.sylvain wrote:
>> For instance I should like to make F9 stand for papa
>> Following VIM Manual (by Moolenaar) I type :
>> :map <F9> ipapa<Esc> (5 characters for <Esc> and 4 characters for <F5> )
>
> That works for me, when typed on Vim's command line, omitting your
> bracketed comment. In .vimrc there'd be no leading ':'.

In .vimrc it is absolutely insignificant whether there is a leading :
or there is no. It is explicitly ignored in do_one_cmd, this behaviour
is also somewhat documented (:h cmdline-lines, search for `colon`,
maybe also somewhere else because this only talks about separating
range and command with a colon).

I usually use colons to prefix commands in `:command`/`:autocmd`
definitions (to separate other arguments with the command executed).
This is not only me: e.g. 2html standard (shipped with Vim) plugin
also defines :TOhtml command as `:call …`.
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

aubertin.sylvain

unread,
Jul 24, 2015, 4:01:56 AM7/24/15
to vim_use, aubertin...@sfr.fr
Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
Following Zyx I looked at :h :map-special-keys, in which I found the following example: :map <F9><Esc>OP :echo "yes"<CR>
Ityped it and vim replied: impossible to modify, 'modifiable' is desactivated.
So there is somewhere the possibility to activate 'modifiable'. Do you know where? MANY THANKS

Paul Isambert

unread,
Jul 24, 2015, 8:24:31 AM7/24/15
to vim...@googlegroups.com
That’s because you must have tested the mapping in a buffer containing
the help file, which is non-modifiable by default (and you probably
don’t want to modify it). Try it with an ordinary buffer.

Anyway the answer to your original request was probably John’s reply:
you’re looking for an insert mode mapping and you have defined a
normal mode one instead.

Best,
Paul

aubertin.sylvain

unread,
Jul 29, 2015, 1:22:00 AM7/29/15
to vim_use, aubertin...@sfr.fr
Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
AT LAST I USED F9 WITH SUCCESS
1. I load my shell with « vim shellname »
2 I see my shell. At the bottom (on the left side ) I find the name of my shelL Please What is the name of this mode ? On my text I can delete usimg x or dd. But F9 gives me nothing.
3 I go to another mode whose name I ignore again. It is in two parts. Above I have the text of my shell and below I have a list which contains ancient commands
4 I find my map command and enable it with a CR. List disappears.
5 I go back to my shell. THIS TIME WHEREVER I AM IT INSERT.S « papa » WITH SUCCESS
I repeat I do that outside insert mode.
So map works if it is freshly enabled. I think it is impossible to have a permanent :map

Paul Isambert

unread,
Jul 29, 2015, 3:06:30 AM7/29/15
to vim...@googlegroups.com
Le mercredi 29 juillet 2015 à 07:22, aubertin.sylvain a écrit:
> Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
> > For instance I should like to make F9 stand for papa
> > Following VIM Manual (by Moolenaar) I type :
> > :map <F9> ipapa<Esc> (5 characters for <Esc> and 4 characters for <F5> )
> > But it doesn't work. Instead of « papa «  , it returns <F9>
> > Something is wrong, but where ?? Thanks for your reply.
>
> AT LAST I USED F9 WITH SUCCESS
> 1. I load my shell with « vim shellname »

That means you load a file named “shellname”.

> 2 I see my shell. At the bottom (on the left side ) I find the name of my shelL Please What is the name of this mode ? On my text I can delete usimg x or dd. But F9 gives me nothing.

That sounds like normal mode.

> 3 I go to another mode whose name I ignore again. It is in two parts. Above I have the text of my shell and below I have a list which contains ancient commands

That sounds like the command-line window. Did you type “q:”?

> 4 I find my map command and enable it with a CR. List disappears.

Yeah, that’s the command-line window.

> 5 I go back to my shell. THIS TIME WHEREVER I AM IT INSERT.S « papa » WITH SUCCESS
> I repeat I do that outside insert mode.
> So map works if it is freshly enabled. I think it is impossible to have a permanent :map

It depends on what you mean by “permanent”. If you mean “from one Vim
instance to the next”, well, yes that’s impossible, but that’s also
pretty much what a .vimrc file is used to: to store command you want
executed every time you open Vim.

Now I’m sorry if I’m a bit rude, but judging from your interventions
here I must ask: did you read the ... manual?

Best,
Paul

aubertin.sylvain

unread,
Jul 29, 2015, 9:34:25 AM7/29/15
to vim_use, aubertin...@sfr.fr
Le mardi 21 juillet 2015 10:02:15 UTC+2, aubertin.sylvain a écrit :
It is marvellous to find people like you. Your replies are so quick. I think manual is good for mkdir, install, apt-get etc. But for modes I must see elsewhere. Vim is very strong but difficult.
The way I leaved normal mode, for command Line Window , I found it after many trials.
First I type :!(CR) Vim says CR or quit. I type q , and after : There I am. If you know a better way please tell me. Again many thanks
Reply all
Reply to author
Forward
0 new messages