I'm new to editing html with VIM. I'm using matchit, ultisnips and surround to help me along the way.
One area which I can't seem to accomplish easily is editing attributes.
I want to go from: (cursor is |)
<input type="submit|" name="some_name" value="" id="some_name">
to:
<input type="submit" id="submit_button">
What is the fastest way to do this? Right now, I'm doing a lot of 'f' based searches.
Possible solutions
wd2W
This method requires counting so maybe you would rather do wdW
and just hit .
until it is correct.
wd/ id<cr>
Moves to the next word so the start of name=".."
the delete with d
til / id
. This solution can also delete across lines. You can use /...
with other operators as well, e.g. c
, y
, and =
.
Of course you can do the method you are using currently with f
and just repeat with .
I usually just use dW, which deletes the name, equals character and the value in parenthesis (including the parenthesis).
In some cases if I want to delete the rest of attributes to the end of the HTML tag I'm using dt/ (delete everything until you find / which is the end of input tag <input ... />)
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