0

I have just started using vim. Due to that I don't instinctively hit the x/X key to backspace. This causes me problems as the backspace key moves you over as if you were hitting h in command mode. I wanted to know if there was a way I could disable this so that in command mode the backspace button does nothing.

I tried looking this up online and I found this:

On some Linux systems, pressing backspace in xterm or uxterm will move the cursor left (without deleting the character). To fix, add:

xterm.*backarrowKey: false

To your .Xresources file and run:

xrdb -merge ~/.Xresources

credit: http://vim.wikia.com/wiki/Backspace_and_delete_problems

But it did not change anything. I am running vim on the command line in Bunson labs.

Any help you can give me would be great.

3
  • Mapping it to <Nop> should work. Try :nmap <Backspace> <Nop> in vimrc or command line
    – SibiCoder
    Jul 27, 2016 at 7:41
  • 4
    Leave it as it is. If it annoys you, you'll stop doing it eventually :-)
    – Antony
    Jul 27, 2016 at 11:15
  • This is an alternate solution, but if you would like backspace to actually delete text, you can add set backspace=2, and backspace should work. It doesn't disable backspace like you asked, but it still fixes your problem.
    – DJMcMayhem
    Jul 27, 2016 at 16:55

1 Answer 1

3

I think you mean you want to remap backspace in normal mode, not command mode. You can do this using :nnoremap <backspace> <nop>. 'nnoremap' allows you to remap keys in normal mode, <backspace> indicates the backspace key and <nop> indicates that it should do nothing.

Since you're new to Vim, I would like to point out that you enter these commands in Vim (just press all the keys in the code sections consecutively on your keyboard). The key will be remapped until you close Vim. If you want to permanently disable to key you could add this command as a line to your .vimrc. If you seriously want to start using Vim, I can highly recommend the this tutorial. It covers the basics of Vim script (the language used to customize Vim) and gives you a good overview of the extend to which Vim can be customized. It is a pretty long read though. In general, I have also found the help system of Vim to be very good. Have a look at :help :nnoremap for more info on remapping for example.

2
  • 2
    Command mode is the same as normal mode.
    – jamessan
    Jul 27, 2016 at 16:30
  • thanks that helped and yes i wanted normal not command mode Jul 27, 2016 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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