Is there a tool that can compute how many keystrokes are need to modify a file to another?

3 views
Skip to first unread message

Peng Yu

unread,
Dec 22, 2009, 6:23:20 PM12/22/09
to vim_use
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.

Christophe-Marie Duquesne

unread,
Dec 22, 2009, 7:34:05 PM12/22/09
to vim...@googlegroups.com
On 12/23/2009 12:23 AM, Peng Yu wrote:
> 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.
>
>

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

Peng Yu

unread,
Dec 23, 2009, 10:27:53 AM12/23/09
to vim_use

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.

Sven Guckes

unread,
Dec 23, 2009, 11:18:36 AM12/23/09
to vim_use
* Peng Yu <peng...@gmail.com> [2009-12-23 16:53]:

> 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

Chris Jones

unread,
Dec 23, 2009, 12:45:50 PM12/23/09
to vim_use
On Wed, Dec 23, 2009 at 11:18:36AM EST, Sven Guckes wrote:

[..]

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

Gary Johnson

unread,
Dec 23, 2009, 1:12:15 PM12/23/09
to vim_use

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


Christian Brabandt

unread,
Dec 23, 2009, 1:31:18 PM12/23/09
to vim_use
Hi Peng!

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.

Dominique Pellé

unread,
Dec 23, 2009, 2:25:14 PM12/23/09
to vim...@googlegroups.com
Peng Yu wrote:

> 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

Erik Falor

unread,
Dec 23, 2009, 3:20:29 PM12/23/09
to vim...@googlegroups.com
On Wed, Dec 23, 2009 at 05:18:36PM +0100, Sven Guckes wrote:
> 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"?

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

signature.asc

Matt Wozniski

unread,
Dec 23, 2009, 4:09:30 PM12/23/09
to vim...@googlegroups.com
On Wed, Dec 23, 2009 at 3:20 PM, Erik Falor wrote:
> At the most fundamental level, one can record a single macro of their
> editing session
...

> 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.

Unless, of course, they wanted to use macros. ;-)

~Matt

Tim Chase

unread,
Dec 23, 2009, 5:03:08 PM12/23/09
to vim...@googlegroups.com
Dominique Pell� wrote:
> '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.

...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

Ben Fritz

unread,
Dec 25, 2009, 10:44:11 AM12/25/09
to vim_use

You could use the -w startup flag rather than a macro. I assume macro
recording still works with -w?

Paul

unread,
Jan 1, 2010, 12:30:11 PM1/1/10
to vim...@googlegroups.com
On Tue, Dec 22, 2009 at 03:23:20PM -0800, Peng Yu wrote:
>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.

At the risk of sounding obvious, it would be however many keystrokes it takes to do this:

:!cp <file1> <file2>

--

.

Tony Mechelynck

unread,
Feb 19, 2010, 9:08:00 PM2/19/10
to vim...@googlegroups.com, Peng Yu
On 23/12/09 00:23, Peng Yu wrote:
> 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.
>

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.

Reply all
Reply to author
Forward
0 new messages