Dnia Wtorek, 20 Sierpnia 2013 18:16 tjg <[email protected]> napisał(a) 
> 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  
> 

What about more program approach using VimL - but you need to use whole 
function for that. Just to get number (don't sure where you want insert those 
numbers):

navigate to line with your week date and:

:echo ceil(split(getline('.'), '\s\+')[1]/1500.0)
15.0

for 'feuillets' (in Poland it is called 'standardowy maszynopis' and has 1800 
characters BTW)

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

:let a=split(getline('.'), '\s\+') | echo a[2]/a[3]
11

Note: here you will get full number which Vim will always round down.

getline('.') - read current line
split(getline('.'), '\s\+\) - split current line into numbers without any 
whitespace
ceil() - round upward
a[2], a[3] - operate on numbers

m.


-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to