Well, with diff and wc, depending on what you call "roughly" and
depending on the text editor, you may obtain a satisfying result...
What about
diff <file1> <file2> | wc --chars
On Dec 23, 6:34 pm, Christophe-Marie Duquesne <chm.duque...@gmail.com>
wrote:
This is too rough.
I want a tool that can at least take consideration of copy and paste
(e.g. 'yy' and 'p'). Or better, given a set of commonly used vim
editing commands, to find the optimal number of keystrokes that are
needed to achieve the final result. Essentially, I want to evaluate
how much time it is need to edit a given file by a human being.
years ago i had asked Bram to add some options to
keep statistics of the tzping - but he reclined.
i still would find this very useful - and fun! :)
Bram - would you reconsider?
vim-8.0 with "typing stats"?
Sven
[..]
Hi Sven,
> years ago i had asked Bram to add some options to keep statistics of
> the tzping - but he reclined. i still would find this very useful -
> and fun! :)
> Bram - would you reconsider?
> vim-8.0 with "typing stats"?
I hope he does, as soon as he's done 'reclining', that is..
;-)
CJ
That would be a _huge_ task with little utility.
For one thing, if you have a good estimate of what the final file
would look like for comparison, you wouldn't need to edit the first
file--you'd be better off starting with your estimate of the final
file.
Secondly, a program's determination of the "optimal" editing tasks
is likely to be different from a person's choice.
Thirdly, the time I spend editing a file is not spent typing--it's
spent thinking about the meaning of the changes that I'm making.
I think the number of keystrokes needed to edit a file is a pretty
meaningless metric, unless you're comparing editors. You'd be
better off measuring how long it actually takes a person of a
similar skill set to make similar types of changes to a
similarly-sized file.
Regards,
Gary
On Mi, 23 Dez 2009, Peng Yu wrote:
> I want a tool that can at least take consideration of copy and paste
> (e.g. 'yy' and 'p'). Or better, given a set of commonly used vim
> editing commands, to find the optimal number of keystrokes that are
> needed to achieve the final result. Essentially, I want to evaluate
> how much time it is need to edit a given file by a human being.
I don't see how that helps, cause usually there are many different ways
to achieve the same result. For example you might manually change every
line and append a value while the next user simply uses a regex. Or one
user uses a normal mode command to achieve something and the next user
uses an ex command. Additionally using multitasking this measure is
actually useless. I usually switch a lot between different applications
so I would look bad on that.
Having said that, you could probably create a script that records all
keys pressed, but I doubt this would be useful either.
regards,
Christian
--
hundred-and-one symptoms of being an internet addict:
33. You name your children Eudora, Mozilla and Dotcom.
> I'm wondering if there is a tool that can roughly estimate how many
> keystrokes (in vim) are needed to modify a file to another.
'diff -e' does that: it outputs an 'ed' script (see 'man diff').
So the lengh of 'diff -e' output gives you the number of
keystrokes.
Of course, it won't give you the minimal number of keystrokes
in Vim. Finding the minimal number of keystrokes would be
quite a challenge.
-- Dominique
At the most fundamental level, one can record a single macro of their
editing session, save that out to a file, and perform whatever
analytics on that they wish. wc -c would give the number of
keystrokes used. You could count ^[ chars to see how many times
insert or visual mode were entered/exited.
This wouldn't help the OP much, but would make possible Vim-Golf
competitions to see who could transform a given file into a designated
form through the least effort.
--
Erik Falor
Registered Linux User #445632 http://counter.li.org
Unless, of course, they wanted to use macros. ;-)
~Matt
...and an NP-complete sort of problem like the TSP. You'd have to
enumerate all possible solutions (possibly an infinite number of
solutions) and then do character counts for each.
I second the "diff -e" approximation.
-tim
You could use the -w startup flag rather than a macro. I assume macro
recording still works with -w?
At the risk of sounding obvious, it would be however many keystrokes it takes to do this:
:!cp <file1> <file2>
--
.
I suppose you aren't going to accept my solution, but if the "model
file" is there for comparison (and if it isn't, you can't estimate the
keystrokes), then copying it over the other file is a trivial solution
to the problem; and on Windows that solution is O(1) on [i.e.
proportional to] directory tree depth, because on that OS every file or
directory has a "short name" no longer than 12 characters (plus one for
the \ separator; and the X: drive letter at the start is itself O(0),
thus negligible). In Vim, if both files are already open, that O(1) part
is already taken care of, and what remains is O(0), namely, something like
:n
:sav! #
:up
(where the last command should be :up! if the file you are trying to
change may be a read-only file).
Best regards :-P
Tony.
--
Pecor's Health-Food Principle:
Never eat rutabaga on any day of the week that has a "y" in
it.