I'm regularly editing CSS in Vim and need to change a value like:
width: 300px;
to something else like:
width: 178px;
Normally what I do is navigate to the 3 in 300 and type cw
to change the word. But if I do this I have to type the px
bit again. Is there a short and quick way to say change in digits
.
In my searching I've discovered Ctrl-a and Ctrl-x to increment and decrement numbers in this situation. Is there an equivalent for being able to retype the number?
I should clarify that the ideal solution would require the fewest keystrokes at time of operation and support modifications to different length numbers. Like if I wanted to change 300px to 17px.
Here is
in
, a custom text-object that lets you act on numerical values (including floats):The actual search is performed in a function to avoid clobbering the search register and search highlighting.
You can add that text-object to your
vimrc
"as is" and use it like other text-objects:--- edit ---
This new version:
Comments welcome.
--- edit ---