VIM suddenly changed deleting style

Discussion in 'Mac Programming' started by ScKaSx, Dec 15, 2007.

  1. ScKaSx macrumors regular

    Joined:
    Feb 27, 2006
    #1
    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
     
  2. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #2
    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.
     
  3. ScKaSx thread starter macrumors regular

    Joined:
    Feb 27, 2006
    #3
    A fellow VIMer, cool.

    Actually, I'm talking about when I'm in INSERT mode and I hit the DELETE key.
     
  4. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #4
    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?
     
  5. ScKaSx thread starter macrumors regular

    Joined:
    Feb 27, 2006
    #5
    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
     
  6. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #6
    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)
     
  7. titaniumdecoy macrumors member

    Joined:
    Oct 13, 2005
    #7
    You can get the functionality of the backspace key by holding fn while you press delete.
     
  8. ScKaSx thread starter macrumors regular

    Joined:
    Feb 27, 2006
    #8
    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
     
  9. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #9
    Get rid of the 'set'. Just put in 'fixdel' at the end of your vimrc file.
     

Share This Page