Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Meta-Function key combination in Vim?

Tags:

vim

I'd need to redefine keyboard mappings of Vim in non-gui mode.

I simply don't understand why the following command does not work:

:set <M-F5>=^[[15~

"E518: Unknown option: <M-F5>=^[[15~"

whereas mapping of alone F5 key or Meta with non-function key does work:

:set <F5>=^[[15~

"ok"

:set <M-space>=^[[15~

"ok"

How to redefine Alt/Meta with function keys F1-F12 in Vim ?

Thx in an advance.

David

Update: Question correction In my .vimrc I have the following key-combination mapping

autocmd Filetype python noremap <buffer> <silent> <M-F9> :w !pylint -E %<CR>

but it does work only in gVim. It unfortunately does not work in non-gui version of Vim, because Vim recieves escape sequence "^[[20~" instead of direct Meta-F9 keycode.

like image 825
David Unric Avatar asked Nov 05 '22 06:11

David Unric


1 Answers

Here's an example from Vim wiki:

inoremap <M-i> <Tab>

Take a look here:

  • http://vim.wikia.com/wiki/Avoid_the_escape_key

In case that doesn't work, try this:

inoremap <ESC>i <Tab>

Note this is a hack and will yield a few wierd things that you will just probably have to live with.

For function keys, something like this should work:

nnoremap <ESC><F9> :ls<CR>
like image 118
icyrock.com Avatar answered Nov 15 '22 04:11

icyrock.com