If I'm in command mode, how do I backspace? Hitting the delete key on my Macbook just moves the cursor to the left one space. The fastest way I know to do this is h, x
, but is there a better way, maybe with one key?
You will see list of commands that matches characters in front of the cursor by pressing CTRL-D in the command mode. For example, if you pressed :se in normal mode, then pressed CTRL-D , you will see list of commands that start with se .
Its the fn key and backspace ( <X) ) or alt and backspace ( <X) ). I think what TK is getting at is a way to forward delete without breaking hand position on home row, in the same quick way you can backspace with Ctrl-H. It's an important capability for maintaining high editing speed and minimizing repetitive strain.
To delete one character, position the cursor over the character to be deleted and type x . The x command also deletes the space the character occupied—when a letter is removed from the middle of a word, the remaining letters will close up, leaving no gap.
x deletes to the right, X deletes to the left
This may be useful for you: Vim Cheat Sheet
In command mode, r might also be useful in some circumstances. It allows you to replace a single character under the cursor.
Typically I often use rSpace, to remove a character on a line without changing the indentation or alignement.
For example if you have the following code :
var anotherOne = NULL;
var short1 = NULL;
var veryLongLong = NULL;
by using rSpace on '1', your now have :
var anotherOne = NULL;
var short = NULL;
var veryLongLong = NULL;
instead of
var anotherOne = NULL;
var short = NULL;
var veryLongLong = NULL;
In the latter case, you must switch to insert mode to add another space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With