Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
Hi All,

Sorry this isn't exactly a programming problem, but I use VIM to write my code so in that sense it is for me. (We really need a unix section)

Anyways, all of a sudden when I'm in VIM it deletes characters behind the cursor rather than the ones in front of it! I'm not sure if I accidently gave it a command to do this or not.

Does anyone know how I can change this preference, or what setting I should specify in my .vimrc?

Thanks,
ScKaSx
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
Glad to see another vim user on this board..

Are you sure your caps lock isn't on so that when you type 'x' you're really typing 'X'? 'X' deletes backwards one char.
 

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
A fellow VIMer, cool.

Actually, I'm talking about when I'm in INSERT mode and I hit the DELETE key.
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
Well, the good news is that what it's supposed to do.

What keyboard are you using? Does it have a backspace and a delete key? On the apple keyboard (or at least the wireless full keyboard I'm using) there's a Delete key right next to the +/= key, and a Delete/Backspace key right above the arrow keys.

(below '^' denotes the Control key):

Note:
ASCII BS == 0x08 == ^H
ASCII DEL == 0x7f == 0177 == ^?

In vim, deleting characters in insert-mode with the Delete key (or ^?) defaults to deleting the last character to the left of the cursor. The Backspace key (or ^H) deletes to the right.

If you're keyboard is missing the extra delete/backspace key, then you should be able to map the delete key to the backspace key (or their control sequences, or even their ascii hex values if it's possible??) in your vim session or .vimrc file this way:

:map! ^? ^H

Also, what version of vim are you using? Are you using the one that came with Mac OS X or is it one you installed via macports or fink?
 

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
Hi Yeroen,

Thanks for all the help btw.

Anyways, I have a macbook pro (intel) running 10.4.10 so I don't have a backspace key just a delete key(which was deleting to the left of the cursor up until recently).

I am using VIM 7.1 which I installed from FINK.

I still have no clue whats happening here, its very strange.

Cheers,
ScKaSx
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
Ok I was confused. I thought you wanted it to delete to the right of the cursor.

In that case, put this line in your .vimrc and see if it works:

:fixdel

(If that doesn't work, then does the delete key delete characters to the left as you expect it to when typing in text at the terminal?)
Alternate suggestion 1: Try vim as another user; if it works for another user, then the problem is your environment settings
Alternate suggestion 2: Try the Mac OS X provided version of vim (under leopard anyway it's 7.0)
 

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
Thanks Yeroen

Actually, :fixdel only works when I issue the command an active vim session. For the config. file set fixdel doesn't work!

Cheers,
ScKaSx
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.