(Re)Mapping Command-Shift-Arrow Keys in Janus/MacVIM

Jan 26 2012

Users of the Janus VIM suite may notice a change in the newest version of Janus. In previous versions, one could navigate around split panes (including to and from the file browser) by holding down COMMAND-SHIFT and then typing one of the arrow keys. This feature has been removed from the latest versions of Janus (I'm guessing because of some other conflict).

Here's how to add that back in.

  1. Open your ~/.vimrc.after file.
  2. Add the code shown below.
  3. Save and restart VIM. <!--break--> ## The Code

In stock VIM, the CTRL-w combinations are used to navigate between panes (windows) in a split-pane view. Janus originally remapped these original mappings, but has now removed those mappings. All we're doing is re-adding those mappings back into the system. The best way to do this in Janus is to edit the file ~/vimrc.after. This file may not exist, so you may need to create it.

This code remaps several CTRL-W functions to the COMMAND-SHIFT arrow keys.

if has("gui_running")
  map <D-S-RIGHT> <C-w>l
  map <D-S-LEFT> <C-w>h
  map <D-S-DOWN> <C-w><C-w>
  map <D-S-UP> <C-w>W
endif

Note that as I have it set above, it will only run the remapping when I am in GUI mode. This is because my terminal emulator already maps that sequence, and when I run VIM in the terminal, I don't want to override existing mappings.

Also worth pointing out is that I have mapped the UP and DOWN sequences to cycle through all windows. So if you press COMMAND-SHOFT-DOWN multiple times, it will wrap back to the top window eventually. If you don't like that behavior, change <C-w> <C-w> to <C-w>k and <C-w>W to <C-w>j.

Again, you may need to restart VIM in order for these changes to take place.



comments powered by Disqus