Reputation: 2654
Given this line of text in vim, where the cursor is located at the caret, and the user is in command mode:
sales_tax: row["sales tax"] ,
____________________________^
What is the fastest way to delete the space between the ]
and the ,
?
Upvotes: 27
Views: 20639
Reputation: 16138
There are already two great answers here. Let's assume you really want the backspace button to delete the previous character while in normal mode. You can change that behavior with this line in your ~/.vimrc
file:
nnoremap <silent> <backspace> X
This will tell vim to issue the X
command (as noted in Axnyff's answer) whenever you hit Backspace in normal mode. I think I like this; it now lives in my ~/.vimrc
.
There are precious few available keys for mapping and Space and Backspace (mapped by default to l and h respectively) seem decent candidates for other functionality. I find this mapping intuitive and helpful, but that's a subjective call. It may or may not be desirable to you.
If you worry about what might happen without the mapping, it'll be pretty straightforward: you'll move the cursor onto the character you want to delete (and then you'll hit x, resulting in the same number of keypresses as h+x or Shift+x).
Upvotes: 0
Reputation: 559
Simple hx
(meaning move left + del char) in command mode is also an option.
Upvotes: 7