I want to do something similar to this question VI (VIM): delete/change right to left? i.e. delete from the end of a line to the last instance of = in that line, which can be done using dT=
with the cursor placed at the end of the line.
However this and other such commands do not delete the final character of the line, so I have to add an x
to that command. I don't mind doing this, yet it seems surprising that vim wouldn't have a command to delete from the current character. Is there one that I just haven't been able to find?
if your cursor is at the end of the line, you could try
F=D
oh, didn't notice that OP wants to keep the '='. then:
T=D
Alternatively, you can:
set virtualedit=onemore
This will let you move the cursor one characer beyond the end of the line. From that position, dT=
will work as you expect.
What about using T=d$
? would that work?
An alternative is to :set virtualedit=onemore
, such that you can do: $dT=
.
Reference at :help 've'
.
A bit more convoluted, but more powerful - I'm not sure if you intend to do one line at a time, or lots... use regular expression replace.
single line:
^ # go to beginning of line
:s/=[^=]*$/=/ # remove everything after =
whole file:
:%s/=[^=]*$/=/gc # replace every instance in file, with prompts. remove c for no prompt.