Tuesday, October 27, 2009

SunOS, backspace and vi

Are you a Linux user forced to use SunOS for a part of your work? Simply navigating around shell and vi is a major PITA. How can it not be if backspace and delete don't work? After some looking around I came up with a pretty standard bash solution of .inputrc config. See the file below - it solves all the problems and makes SunOS behave just like Linux. It also lets you search your bash history with up/down arrow keys (type something and then hit up/down and it will find commands that start with these characters).



.inputrc
$include /etc/inputrc

set bell-style none
set completion-ignore-case on

# linux console
"\e[3~": delete-char
"\e[7~": beginning-of-line
"\C-[[8~": end-of-line
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# konsole
"\e[H": beginning-of-line
"\e[F": end-of-line

"\e[B": history-search-forward
"\e[A": history-search-backward


And then came vi. I never actually used vi. I was always a vim user (are there pure vi users left at all?). I also always thought that vim was a slightly improved version of vi. I couldn't have been more wrong. Vi doesn't support arrow keys in insert mode and page up/down, backspace and delete in any mode at all (at least in the expected usage of these keys). After 3 hours of googling and playing with .exrc I finally gave up. Turns out vi just can't use arrows in insert mode and getting backspace to work sounds more like an urban legend than reality (although I have seen allusions to it on some forums).

P.S. Meanwhile study this vi cheat sheet and hope for best :)

No comments:

Post a Comment