Suppose I'm editing a text file, and I'm working through a tradeoff
between data volume and accuracy, where more accuracy requires
more data. I have an array of 14 sensors, and I can configure them
to take either 100-byte samples or 500-byte samples, and I can take
samples at intervals between 1 and 60 seconds.
Now, I want to know bytes per day, and this is where the math comes in.
I start adding columns. First I duplicate the three existing columns,
since I want to see them next to the result. I can do this by putting
a cursor at the beginning of each row, highlighting the whole thing,
and pasting. I also hit & to line up the pasted selections.
Now, because I don't want to have to think about the stack too hard,
I put 1440 (minutes per day) and 60 (seconds per minute) in before
the interval column.
Now each line has a little dc program on it, like 14 500 * 1440 *
60 * 60 / p.
I then highlight the back half of each row (again, still working
with the same set of cursors the whole time, it takes way longer to
explain this than it does to actually do it.) I type
| dc
and each of my selections gets run through dc. The result is:
Thanks! This is pretty cool. I do often run shell commands on entire lines/ranges of lines in vim, but haven't tried it with just parts of lines. I just tried with vim's rectangular selection, and while it does correctly give the 'dc' output, it replaces entire lines with the output instead of just the selection. I'll have to look into this further.
Enjoy! Kakoune’s selection-verb editing model really clicked for me; I had been a heavy user of visual mode in vim before I switched. The great Unix integration composes really well with the selection model too.
Suppose I'm editing a text file, and I'm working through a tradeoff between data volume and accuracy, where more accuracy requires more data. I have an array of 14 sensors, and I can configure them to take either 100-byte samples or 500-byte samples, and I can take samples at intervals between 1 and 60 seconds.
So I make myself a little table:
Then I duplicate it: I'm using kakoune, so I can put my cursor on the 100 in the first duplicate row, press C twice, then press r5, and now I have this table: Now, I want to know bytes per day, and this is where the math comes in. I start adding columns. First I duplicate the three existing columns, since I want to see them next to the result. I can do this by putting a cursor at the beginning of each row, highlighting the whole thing, and pasting. I also hit & to line up the pasted selections. Now, because I don't want to have to think about the stack too hard, I put 1440 (minutes per day) and 60 (seconds per minute) in before the interval column. Then I add my operations. And keep in mind I'm still using multiple cursors, so all this stuff is just getting typed one time. Now each line has a little dc program on it, like 14 500 * 1440 * 60 * 60 / p.I then highlight the back half of each row (again, still working with the same set of cursors the whole time, it takes way longer to explain this than it does to actually do it.) I type
and each of my selections gets run through dc. The result is: That's not super readable, so I cursor over three times (multiselection is still active!) and insert commas, and then I do it again: The result is I've done a quick back-of-the-envelope calculation on how much data I need to handle in each scenario.