Putty and VIM

Since I started working for the Moodle HQ, I've changed from using Eclipse for PHP development to using vim through a PuTTy window. I am much happier with vim for a number of reasons, not the least being the speed, the community support and the ease with which it can be customised.

However, working through PuTTy can be a bit tricky if it isn't set up properly. Delete, backspace, home and end keys don't always act as I would like them to.

After trying a number of solutions I found while Googling around, I found a great one that works perfectly for me:

From the linux shell:
> export TERM=putty

In PuTTy's config panel, under Connection->Data->Terminal Details->Terminal-type string, type 'putty'

The purpose of changing the terminal type to putty is to alter the behaviour of keys slightly, as well as enable more colours if you have set up these correctly in your .vimrc file.

Still in Putty's config panel, Terminal->Keyboard set "The Backspace Key" to ctrl-?, "The Home and End Keys" to normal and the "Function Keys and Keypad" to ESC[n~

Then, in Terminal->Features, leave everything unticked except "Disable application keypad mode".

Finally, in your vimrc file (typically ~/.vimrc) make sure you have
set bs=2

This activates the "normal" backspace function, which erases all text before the cursor, one char at a time. Otherwise the key may only erase characters that have been typed since the last time you entered insert mode. This also enables the wrapping to the previous line when reaching the beginning of the line, or wrapping of the next line near the cursor if using the delete key. These settings mimic more closely the behaviour of text editors on windows.

I hope you find this useful :-)

Note: some of these settings are different, depending on the version of PuTTy you are using. I'm using 0.60

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

keyboard set to "Linux"

Thank you for this comments, very useful.

I had better success with setting "The Function keys and keypad" to "Linux"
(PuTTY on WinXP, German edition).

Try setting the font to "Lucida Console, 11-point", pretty readable.