I can't "remap" <Shift-F4> key

2 views
Skip to first unread message

ludo

unread,
Dec 9, 2008, 2:51:48 AM12/9/08
to vim...@googlegroups.com
Hi,

I'd like to map ":cprev" to <Shift-F4>
I use (in normal mode)
:map <S-F4> :cprev <CR>

But when I press the <Shift-F4> key, Vim displays the message 'Already
an oldest change'
Maybe, <Shift-F4> is a "reserved" combinaison key for Vim ?

if I try
:map <F4> :cprev <CR>
that works

what is wrong ?

Jürgen Krämer

unread,
Dec 9, 2008, 4:15:08 AM12/9/08
to vim...@googlegroups.com

Hi,

you probably have a buffer-local mapping like

:map <buffer> <S-F4> u

defined somewhere. You can check this with

:map <S-F4>

This should show something like

<S-F4> @u
<S-F4> :cprev <CR>

The mapping with the ampersand is the buffer-local one and this takes
precedence over the second one.

If you want to know where the first mapping was defined execute

:verbose map <S-F4>

and you get something like

<S-F4> @u
Last set from c:\map_u.vim
<S-F4> :cprev<CR>

Regards,
Jürgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)

ludo

unread,
Dec 9, 2008, 4:49:22 AM12/9/08
to vim...@googlegroups.com
Jürgen Krämer a écrit :
> Hi,
>
> ludo wrote:
>
[...]

> you probably have a buffer-local mapping like
>
> :map <buffer> <S-F4> u
>
> defined somewhere. You can check this with
>
> :map <S-F4>
>
> This should show something like
>
> <S-F4> @u
> <S-F4> :cprev <CR>
>
unfortunately, when I execute
:map <S-F4>
Vim displays 'No mapping found'

> The mapping with the ampersand is the buffer-local one and this takes
> precedence over the second one.
>
> If you want to know where the first mapping was defined execute
>
> :verbose map <S-F4>
>
> and you get something like
>
> <S-F4> @u
> Last set from c:\map_u.vim
> <S-F4> :cprev<CR>
>

and ':verbose map <S-F4>' also displays 'No mapping found'

Maybe, the problem is around the SHIFT key
When I try to use Fx key (F2, ... F12) with the additionnal SHIFT key
for the :map function, it's failed
:map <F4> :do_something
:map <F...> :do_something
:map <F12> :do_something
all succeeded

but when I try
:map <S-F4> :do_something
:map <S-F...> :do_something
:map <S-F12> :do_something
all failed :-(

A. S. Budden

unread,
Dec 9, 2008, 4:56:31 AM12/9/08
to vim...@googlegroups.com
2008/12/9 ludo <ludovi...@gmail.com>:

Check that the operating system isn't getting in the way: go to insert
mode and hit Ctrl-V Shift-F4. If you get <S-F4> then I would expect
the mapping to work.

Al

Jürgen Krämer

unread,
Dec 9, 2008, 4:57:45 AM12/9/08
to vim...@googlegroups.com

Hi,

ludo wrote:
>
> Maybe, the problem is around the SHIFT key
> When I try to use Fx key (F2, ... F12) with the additionnal SHIFT key
> for the :map function, it's failed
> :map <F4> :do_something
> :map <F...> :do_something
> :map <F12> :do_something
> all succeeded
>
> but when I try
> :map <S-F4> :do_something
> :map <S-F...> :do_something
> :map <S-F12> :do_something
> all failed :-(

which system are you on? And what do you see when you enter

<C-V><F4>

and

<C-V><S-F4>

while you are in insert mode?

ludo

unread,
Dec 9, 2008, 6:00:17 AM12/9/08
to vim...@googlegroups.com
A. S. Budden a écrit :
when I hit 'Ctrl-V Shift-F4' => Vim displays ^[[26~
when I hit 'Ctrl-V F4' => Vim displays ^[[14~

I use Vim 7.2 for cygwin with XP

ludo

unread,
Dec 9, 2008, 6:11:54 AM12/9/08
to vim...@googlegroups.com
Jürgen Krämer a écrit :

> Hi,
>
> ludo wrote:
>
>> Maybe, the problem is around the SHIFT key
>> When I try to use Fx key (F2, ... F12) with the additionnal SHIFT key
>> for the :map function, it's failed
>> :map <F4> :do_something
>> :map <F...> :do_something
>> :map <F12> :do_something
>> all succeeded
>>
>> but when I try
>> :map <S-F4> :do_something
>> :map <S-F...> :do_something
>> :map <S-F12> :do_something
>> all failed :-(
>>
>
> which system are you on? And what do you see when you enter
>
> <C-V><F4>
>
> and
>
> <C-V><S-F4>
>
> while you are in insert mode?
>
when I hit 'Ctrl-V Shift-F4' => Vim displays ^[[26~
when I hit 'Ctrl-V F4' => Vim displays ^[[14~

I use Vim 7.2 for cygwin with XP

I have tried on my Debian with Vim 7.1 and the result is similar (:map
<S-F4> doesn't work)


when I hit 'Ctrl-V Shift-F4' => Vim displays ^[[26~

when I hit 'Ctrl-V F4' => Vim displays ^[[[D


Tony Mechelynck

unread,
Dec 9, 2008, 12:35:08 PM12/9/08
to vim...@googlegroups.com

Hm. What is 'term' set in each case. If it is set to different values
(let's assume "cygwin" and "xterm" for the sake of argument; but replace
them below if different), you should be able to cure the problem as follows:

if &term == 'cygwin'
set <S-F4>=^[[14~
elseif &term == 'xterm'
set <S-F4>=^[[[D
endif

where ^[ is obtained by hitting Ctrl-V followed by Esc.

Alternately, use gvim rather than Console Vim: there, your F keys ought
to be detected correctly.


Best regards,
Tony.
--
Fornication, n.:
Term used by people who don't have anybody to screw with.

ludo

unread,
Dec 10, 2008, 9:21:12 AM12/10/08
to vim...@googlegroups.com
[...]

> Hm. What is 'term' set in each case. If it is set to different values
> (let's assume "cygwin" and "xterm" for the sake of argument; but replace
> them below if different), you should be able to cure the problem as follows:
>
> if &term == 'cygwin'
> set <S-F4>=^[[14~
> elseif &term == 'xterm'
> set <S-F4>=^[[[D
> endif
>
> where ^[ is obtained by hitting Ctrl-V followed by Esc.
>
> Alternately, use gvim rather than Console Vim: there, your F keys ought
> to be detected correctly.
>
> Best regards,
> Tony.
>
effectively, ':map <S-F4> :do_something' works fine with gvim
and I will try to customize later my .vimrc with the &term variable

thanks for your help

Reply all
Reply to author
Forward
0 new messages