Tuesday, August 20, 2013

Basic calculation in Vim

I have written a small function which puts "WIP statistics" at the end of the
file (pure text, no code) I am working on.

It looks like this (ts = 7)

Date NbCar NbWords NbSent NbLines
130813 21910 3640 310 180
130820 30310 5210 480 220

(NB : Date in the ymd format, Nb=number, Car=Characters, Sent=Sentences
(separated by .!?…) , and Lines are, of course, non-blank lines and, thus,
the equivalent of book paragraphs).

This function works. But I would like to add 2 "columns" :

- one about the final output : divide the NbCar by 1500 (in France a
journalistic "feuillet"/page, I do not know if there is an equivalent
elsewhere) ; here it would indicate that a week ago I had written 15
feuillets (rounded upwards), and this week, 20 feuillets : a 250 pages book
in a year, "In search of lost time" much later, genius not included…

- one about simple readability : divide the number of words by the number of
sentences.

How should I proceed ?

For the first one (output) I tried to move the cursor on the number (e.g.
30310), enter insert mode then <Ctrl-R>= followed by <Ctrl-R><Ctrl-W>/1500,
but failed miserably.

As for the second one (readability), I simply cannot figure it out.

Thanks in advance



--
View this message in context: http://vim.1045645.n5.nabble.com/Basic-calculation-in-Vim-tp5717021.html
Sent from the Vim - General mailing list archive at Nabble.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: