Tuesday, April 22, 2008

Apple keyboards and .vimrc delete and backspace

From the vim 4.0 docs on backspace and delete:

"In 3.0 both the delete key and the backspace key worked as a backspace in insert mode; they deleted the character to the left of the cursor. In 4.0 the delete key has a new function: it deletes the character under the cursor, just like it does on the command-line. If the cursor is after the end of the line and 'bs' is set, two lines are joined."

Apply keyboards have a delete key -- two, sometimes, actually -- but no backspace key. So users of Apple keyboards effectively have, by default under vim 4.0, no backspace. If you find yourself pressing delete and repeatedly joining a bunch of lines, that's probably what's going on.

The solution's in the next part of the same helpscreen:

If you prefer backspace and delete in Insert mode to have the old behavior, put this line in your vimrc:

inoremap ^? ^H

And you may also want to add these, to fix the values for <BS> and <Del>:

set t_kb=^H
set t_kD=^?

(Enter ^H with CTRL-V CTRL-H and ^? with CTRL-V CTRL-? or <Del>.)

No comments: