vim deleting backward tricks
Solution 1:
In general, d<motion> will delete from current position to ending position after <motion>. This means that:
- d<leftArrow> will delete current and left character
- d$ will delete from current position to end of line
- 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
Read this to learn all the things you can combine with the 'd' command.
Solution 2:
I have been in this scenario many times. I want to get rid of all the spaces in line 10 so it would join with line 9 after the comma.
This is basically a simple line join in VIM.
kJ
does the trick (watch below)
Solution 3:
To answer point #3, diw
and daw
are excellent.