Let's say I've typed "abcdefg", with the cursor at the end. I want to delete back to the c, so that I only have "abc" left.
Is there a command like d
that includes the current character? I know I could do dTcx
, but the x
feels like a work-around and I suppose there's a better solution.
Pressing the <Backspace> key once deletes the character just before the cursor and moves the cursor backward one space. Pressing the <Delete> key once deletes the character under the cursor.
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. You can also delete blank spaces in a line with the x command.
Deleting a single line in Vim editor: To delete a line, follow the steps below: First, bring your cursor to the line you want to delete. Press the “Esc” key to change the mode. Now type, “:d”, and press “Enter” to delete the line or quickly press “dd”.
No. Backward motions always start on the left of the current character for c
, y
and d
which is somehow logical but also unnerving.
The only "clean" solutions I could think of either imply moving to the char after c
first and then do a forward delete:
Tcde
or using visual mode:
vTcd
v3hd
But, given your sample and assuming you are entering normal mode just for that correction, the whole thing sounds extremely wasteful to me.
What about staying in insert mode and simply doing ←←←←?
try this:
TcD
this will leave abc
for your example... well if the abcdefg
is the last word of the line.
if it is not the last word in that line, you may do:
ldTc
or golfing, do it within 3 key-stroke:
3Xx or l4X
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