18

Have you ever noticed that the default vi key bindings on the Raspberry Pi are a little wacky? For example, while in insert mode, try using the arrow keys to navigate. Not happening :)

Is this a subtle way of getting us to use insert and command mode properly or maybe the bindings were just overlooked when the image was built?

I'm quite used to a certain key mapping in Fedora/Debian that allows the use of navigation keys while in insert mode. To get the familiar bindings I'm used to, do I need to fiddle with terminal emulation or some sort of configuration file somewhere?

Caleb
  • 1,186
  • 11
  • 17
Brad Hein
  • 291
  • 1
  • 2
  • 6
  • 6
    I expect it's because you are used to vim and what you're now experiencing is truly vi. On modern distros, the vi command is often syslinked to vim. – Jivings Dec 21 '12 at 18:18
  • Is this through ssh? You might need to even try stty sane and setting your TERM variable (export TERM=linux is usually easiest for me to remember) – Drake Clarris Dec 21 '12 at 19:33
  • Which version? Latest (oct release) seems OK, at least over ssh. – ergosys Dec 21 '12 at 22:30

3 Answers3

22

The default package is vim-tiny. You can install a version that is more familiar:

sudo apt-get install vim

Extra configuration and customization can be placed in the .vimrc file in your home directory.

Bert
  • 842
  • 7
  • 10
2

Remove and purge vim-tiny before installing vim. It will work as expected after that.

user17506
  • 21
  • 1
  • Had to do this as well. vim-tiny and vim seem to depend on different versions of vim-common and that prevents me from installing both. – qznc Dec 22 '19 at 12:02
1

I also had this problem when I logged in as the root user but not the pi user. I have also installed vim with:

apt-get install vim

That didn't solve it alone but a little digging and I discovered that it was some environment variable differences. I managed to get my happy vi behavior of being able to move around with the cursor keys even in insert mode by simply changing the /root/.profile file to read as follows:

if [ -n "$BASH_VERSION" ]; then
  if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
  fi
fi

if [ -d "$HOME/bin" ] ; then
  PATH="$HOME/bin:$PATH"
fi
Tyler B
  • 11
  • 1