Map Shift + F3 in .vimrc

13

3

When using vimgrep with lv expr path/**, I like to have a shortcut for navigating the results. So I mapped the F3 key like the following:

nnoremap <F3> :lnext<CR>

Now I would like to do something like the following

nnoremap <SHIFT-F3> :lprevious<CR>

But this does not have the desired effect. How do I map a F-key with SHIFT?

Update:

The solution is a bit difficult. In terminals you cannot just map Shift+F3. In fact an additional line like the following is necessary:

set <S-F3>=^[O1;2R
nnoremap <S-F3> :lprevious<CR>

But you cannot copy&paste this, see the link below in the right answer.

Trendfischer

Posted 2012-11-21T11:30:54.127

Reputation: 417

Answers

14

You're using Vim in the console, not GVIM, right? Anything other than the plain function keys is problematic, and best avoided; try using a prefix like <Leader> instead. If you really want this, you can try the instructions at http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim for getting function keys with modifiers to work.

Ingo Karkat

Posted 2012-11-21T11:30:54.127

Reputation: 19 513

That link was very helpful, I did not even expected a problem like this. Although it is not the answer I wished to read, it is the right answer in my opinion. And following the advise with fast key codes, I could map the key combination as desired. – Trendfischer – 2012-11-22T08:21:25.487

6

It should be <S-F3> not <SHIFT-F3>, see :help key-notation in Vim.

livibetter

Posted 2012-11-21T11:30:54.127

Reputation: 1 497

Yes, this is the answer I wanted to have, but it did not work this way. You need :set for making it in a terminal to work. – Trendfischer – 2012-11-22T08:22:45.547

0

Nowadays setting extra keycodes for functional keys isn't necessary, all you need is:

nnoremap <s-f3> :lprevious<cr>

Tested on NeoVim.

Somebody please try it on clean VIM so I could update this answer.

cprn

Posted 2012-11-21T11:30:54.127

Reputation: 101