Skip to content

Bash For Windows and VIM Arrow Keys

mrg0029 edited this page Sep 22, 2017 · 5 revisions

Get Bash on Windows arrow keys working properly

Arrow keys will work out of the box if you use the automatically-generated {bash} task.

See the docs for details: https://conemu.github.io/en/BashOnWindows.html

Old workaround for VIM Arrow Keys is obsolete!

This edit may no longer work on the latest conemu builds (as of 5/17/16), and may even impede functioning. Use at your own risk


Reassign ctrl+v == paste keybind in ConEmu settings

Make sure ctrl+v is NOT bound to paste in conemu. (use ctrl+shift+v or something)

In local .bashrc

(AND remote .bashrc - to fix vim in ssh sessions):

if [ -d /mnt/c/WINDOWS ] || [ $LC_WINDOWS10 ]; then
  export WINDOWS10=0
fi
if [ $WINDOWS10 ]; then
  export LC_WINDOWS10=$WINDOWS10
fi

In local .vimrc

(AND remote .vimrc - to fix vim in ssh sessions):

let windows10=$WINDOWS10
if windows10 == '0'
  set t_ku=(ctrl+v , UP arrow)
  set t_kd=(ctrl+v , DOWN arrow)
  set t_kr=(ctrl+v , RIGHT arrow)
  set t_kl=(ctrl+v , LEFT arrow)
endif

In vim, this will appear as "set t_ku=^[[A" or something like that.

With both the bashrc and vimrc changes in place, local and remote vim both have working arrow keys, without breaking arrow keys in non-windows10 shells.

If the issue is not resolved...

The fix requires that /etc/ssh/sshd_config AcceptEnv accepts variables in "LC_", and /etc/ssh/ssh_config (or .ssh/config) SendEnv sends "LC_", which is the default for Ubuntu openssh clients and servers.