Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backward delete till character in Vim

Tags:

dt deletes till the next comma.

a, b, c[,] d, e

dt,

a, b, c[,] e

What is the command to perform same operation in backward direction in order to get:

a, b, d, e
like image 225
Sathish Avatar asked Feb 10 '13 18:02

Sathish


People also ask

How do you delete a word backwards in Vim?

d^ will delete from current backward to first non-white-space character. d0 will delete from current backward to beginning of line. dw deletes current to end of current word (including trailing space) db deletes current to beginning of current word.

How do I delete a specific character in Vim?

Yes, use the "till" motion. means delete until a ". There is also the "find" motion, which deletes up to and including the character.

How do I forward a vim delete?

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.


1 Answers

Often in Vim, the capitalised letter performs the motion in the opposite direction. Thus dT, will do the search backwards. However, you need to use 2dT, so that the first comma is deleted.

For the same reason you need to use df, instead of dt, to delete the comma in your given example.

like image 73
Prince Goulash Avatar answered Sep 22 '22 23:09

Prince Goulash