I want to delete specific char in line, with Vim, for example:
for a, b in enumerate(def}):
If the cursor it is on the beginning, I want to know if is possible to remove the typo {
without moving to the that position.
I already tried f
, t
, |
keys, but as motions keys, they ended up deleting the entire line.
Is there a "pointwise-like" key-movement that will remove that specific char? Or it is not worthy at all?
The simplest version is to move the cursor and then delete (since it’s a single character):
f}x
This is different from df}
—the first reads « find a } and then delete it », while the second reads « delete everything from my current position to where you find a }, inclusive » (t
—‘til—would be the exclusive).
As it turns out, x
is a synonym for dl
, which is « delete a character covered by moving one to the right ». (Yes, I know, hjkl. Trust me, it’s more intuitive if you don’t think about it.)
If you want to go back to the beginning of the line, you can hit 0
after that, or possibly ``
.
In a typo that simple, you could also do
:substitute/}/
Or :s/}/
for short, but that’s a lot of typing.
Overall, there is no reason not to move the cursor.