Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Custom arrow key mappings not working with window switching?

I've been trying to create a shortcut for switching between open window splits in vim, rather than having to use ctrl+w+[arrowkey] I would prefer to just be able to use ctrl+[arrow keys].

This is what I currently have in my vimrc:

map <silent> <C-v> <c-w>v
map <silent> <C-Left> <c-w>h
map <silent> <C-Down> <c-w>j
map <silent> <C-Up> <c-w>k
map <silent> <C-Right> <c-w>l

The first shortcut for doing the vsplit works fine, however none of the others work. I've tried several variations of this and yet none of them do anything.

I'm using standard debian wheezy with KDE, vim is running from konsole and the only plugins I have installed are NERDTree and Airline.

I'm hoping someone can help provide a solution because I've been searching online for hours and trying hundreds of options and nothing seems to make any difference.

EDIT verbatim insert for the shortcuts doesn't output anything at all, neither in shell or vim.

like image 367
historymaker118 Avatar asked Jan 30 '14 15:01

historymaker118


1 Answers

First, make sure that <C-Left> is not handled by konsole. Start a fresh one and use cat:

$ cat
^[[1;5D

That is how it should work for <C-Left>. Similar for other arrows. If <C-Left> doesn't work in such a way, search for "\e[1;5D": ... in /etc/inputrc and ~/.inputrc and comment it. You may have to log out and log in to get effect of these changes.

Next, use

:verbose map

in vim to display all mapped shortcuts and their source. You should see your bindings in this list. Your bindings are correct and all work in my case.

like image 141
Andrey Avatar answered Oct 16 '22 07:10

Andrey