Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to configure following keys in vim?

  • Backspace key to delete a character backwards.
  • Delete key to delete a character forwards.

After reading some posts, I got to know that only one of those can be used to delete a character. But I guess the above behavior would be achievable.

Current scenario

  1. Backspace working as said above.
  2. Delete key is however acting weird. On pressing it, the character under the cursor get's replaced by ~, and later 5-6 keystrokes changes it to aplahabet and also change the case. Vim comes back to normal mode after that, leaving messed-up text.

Details

$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ vim --version
VIM - Vi IMproved 7.0 (2006 May 7, compiled Jun 12 2009 07:08:36)

If the above is not configurable, Please let me know, How I can at-least map Delete key to nothing, so that above weird behavior doesn't take place ?

share|improve this question
2  
What terminal are you using? Is the TERM environment variable set correctly? –  peterph Jan 8 '13 at 13:41
    
In a terminal, what do you see when you type Ctrl-V Del? Compare the output of :echo &term in Vim and echo $TERM in your shell - they should be the same. As mentioned above, make sure the $TERM value is correct, and then make sure the Vim term value matches. –  jw013 Feb 7 '13 at 16:21
add comment

3 Answers 3

In the tcsh shell, add this line in your ~/.cshrc file:

stty erase '^?'
share|improve this answer
add comment

I do that with help of the stty command, just add this line to your .bashrc file:

stty erase ^?

you do that by typing stty erase and then Ctrl-V and finally press the Delete key.

Hope that fixes the problem.

share|improve this answer
    
The weird behavior is still present. –  mtk Jan 8 '13 at 9:57
add comment

All the vim settings have to be done in a file called .vimrc located in $HOME. It is initially empty. I have vim 7.3 and both the keys are working fine. I suggest you to go through this link

http://vim.wikia.com/wiki/Backspace_and_delete_problems#Delete_key_problems

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.