Make F1 function like ESC

1 view
Skip to first unread message

Greg Sieranski

unread,
Jan 11, 2008, 2:44:45 PM1/11/08
to vim...@googlegroups.com
Is there a way to make F1 function like the escape command. I disabled
it from opening help but would now like to make it function like ESC.

Thanks for the help,
Greg

Tony Mechelynck

unread,
Jan 11, 2008, 2:49:03 PM1/11/08
to vim...@googlegroups.com

Well, what about

:map <F1> <Esc>
:map! <F1> <Esc>

?


Best regards,
Tony.
--
From the moment I picked your book up until I put it down I was
convulsed with laughter. Some day I intend reading it.
-- Groucho Marx, from "The Book of Insults"

Tim Chase

unread,
Jan 11, 2008, 2:50:00 PM1/11/08
to vim...@googlegroups.com
> Is there a way to make F1 function like the escape command. I disabled
> it from opening help but would now like to make it function like ESC.


A curse on laptops, the F1 and ESC are often too close together.

In my .vimrc, I've got

:map <f1> <esc>
:imap <f1> <esc>

so when I stab for the ESC key, and accidentally hit F1, it does
what I want.

-tim

Greg Sieranski

unread,
Jan 11, 2008, 2:56:29 PM1/11/08
to vim...@googlegroups.com
thanks, I figured it was something like that. What is the :imap one
needed for?

Greg

Greg Sieranski

unread,
Jan 11, 2008, 3:01:32 PM1/11/08
to vim...@googlegroups.com
Tony Mechelynck wrote:
> Greg Sieranski wrote:
>
>> Is there a way to make F1 function like the escape command. I disabled
>> it from opening help but would now like to make it function like ESC.
>>
>> Thanks for the help,
>> Greg
>>
>
> Well, what about
>
> :map <F1> <Esc>
> :map! <F1> <Esc>
>
> ?
>
>
> Best regards,
> Tony.
>
ok, it looks like I need the :map <F1> <Esc> but do I need :imap <F1>
<Esc> or :map! <F1> <Esc>?

thanks guys,
Greg

Tony Mechelynck

unread,
Jan 11, 2008, 3:08:08 PM1/11/08
to vim...@googlegroups.com

":imap" is for Insert mode. If you want Insert mode _and_ Command-line mode,
use ":map!" with bang instead of ":imap". (":map" without bang is for Normal,
Visual/Select and Operator-Pending.)

See ":help map-overview"


Best regards,
Tony.
--
My God, I'm depressed! Here I am, a computer with a mind a thousand
times as powerful as yours, doing nothing but cranking out fortunes and
sending mail about softball games. And I've got this pain right
through my ALU. I've asked for it to be replaced, but nobody ever
listens. I think it would be better for us both if you were to just
log out again.

Tony Mechelynck

unread,
Jan 11, 2008, 3:10:51 PM1/11/08
to vim...@googlegroups.com

You need ":map!" (in addition to ":map") if you want F1 to work like Esc in
all modes, ":imap" if you want Insert-mode but not Command-line mode.

See ":help map-overview".

Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
229. You spend so much time thinking what to add on this list.

Yegappan Lakshmanan

unread,
Jan 11, 2008, 5:41:33 PM1/11/08
to vim...@googlegroups.com
Hi,

On Jan 11, 2008 11:56 AM, Greg Sieranski <greg.si...@quoininc.com> wrote:
>
> What is the :imap one needed for?
>

You can refer to the tutorial on mapping keys in Vim:

http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_1%29
http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_2%29

- Yegappan

Reply all
Reply to author
Forward
0 new messages