tags:

views:

81

answers:

3

I'm trying to get into Vim. I'm running it in the terminal on OS X.

Anytime I hit the delete key, it simply changes case of that letter instead of deleting it. When I SSH into my server and use Vim there, it deletes normally.

Any ideas what may be going wrong?

Thank you!

+4  A: 

The problem

The Del key generates the code ^[[3~ in my urxvt terminal on GNU/Linux, and might generate a similar code in your OS X terminal.

My theory is that Vim for some reason doesn't recognize any keybinding for the delete key, and simply tries to interpret the string ^[[3~ as input instead. ^[ is the keycode for the Esc key (which puts you in normal mode), and ~ is the Vim command for changing the case of a letter (from normal mode).

You can confirm the keycodes I mentioned by pressing Ctrl+V Esc and Ctrl+V Del from insert mode in Vim. Ctrl+V means that the next character should be inserted as text instead of being interpreted by the editor.

The solution

As for the solution, try editing your Vim configuration file (presumably ~/.vimrc):

vim ~/.vimrc

And append the following code to it:

nmap Ctrl+V Del x

imap Ctrl+V Del Ctrl+V Esclxi

I hope this helps :)

Jabir Ali Ouassou
Off-topic:How do you add graphical keyboard-buttons to StackOverflow posts?
Jabir Ali Ouassou
@A Guy With Really Long Nick: use the `<kbd>Del</kbd>`.
Dummy00001
@Dummy00001: Thanks a lot, I updated my post to use the <kbd> tags :)
Jabir Ali Ouassou
A: 

I use vim regularly on my OSX machine (vim version 7.2.108), and I do not have this issue. Try renaming your vimrc file and then reload vim, and see if the issue persists. If there is no issue after renaming you vimrc file, then your issue is in that file.

On my machine, my vimrc file is pretty much empty:

set ruler
set tabstop=2
set cindent
set number
syntax on
karlw
A: 

The problem was that in my .vimrc I had

set term = ansi

Took that out and all was well - sorry about the troubles, thanks!

Nicky Hajal