I often work on CSS files or other files that require hiding numbers. I would really like to have a key that refers to integers in the sense that w
refers to a word, or (
refers to a sentence. For example, in a css file, I could go to the beginning of the height declaration and change its value without retyping "px "at the end, which happens if I use w
.
Is there such a thing, but I miss it in the documentation, or is there a way to add this function to my .vimrc?
Bonus points if there is a way to use it as ci"
, where I could be at the beginning of the line and use the" change internal "command to go to AND change the next integer.
More bonus points if I could do simple arithmetic. I would love to get a short command that would be short for "Add also, inner, integer, 5" and have the next integer in the current line - five terrays, then it was when I started.
Edit:
Some really great suggestions for everyone, great ideas that will surely improve my work. Thank you Hussek's answer is likely to end up in my workflow, but none of the others seem to have answered (completely) my internal question: a movement that works on integers. The sentence traced by romainl seems to have this purpose , but I cannot get it to work reliably .
For myself (and possibly others) I will clarify my wishes below:
A key that acts mainly like w
acts for words, but on integers, so I can just add it to my mental vim vocabulary and use it without problems. This includes the following scenarios. (I use d
as my sample key):
- Normal mode
d
: move to the next integer - Normal
cd
mode: go to the end of the integer under the cursor (note that cw
is a special case that MUST change to the word NEXT. cw
acts like ce
.) I would expect this special case to be implemented with integers as well. - Visual
id
mode: select the integers [count]. - Visual
ad
mode: select the integers [count]. Running or trailing space is included.
Is there any lack of behavior that w
can expect from a new movement? Is there even a key that is available in both normal and visual modes?
source share