开发者

Productivity analyzer for vim

开发者 https://www.devze.com 2023-04-12 22:28 出处:网络
Background I\'m looking to build productivity analyzer for vim which could silently display more efficient solution for particular, repetitive task the user doing. The tip might be displayed in growl

Background

I'm looking to build productivity analyzer for vim which could silently display more efficient solution for particular, repetitive task the user doing. The tip might be displayed in growl, status line, etc.

Don't laught, but the idea come from Clippy: http://en.wikipedia.org/wiki/Office_Assistant Of course I don't want to build another funny stuff like vigor I'm about serious efficiency analizement which could be especially useful for vim newbies.

The question

Does it makes sen开发者_如何学JAVAse and is there any theory covering such analysis?


Off the top of my head:

  • This would require a fair amount of AI/fuzzy classification. It is hard to analyze what the user is 'trying to do' (often the user is not clear and will get sidetracked: Oh, fix that typo while I'm here; align that comment... ok, now on with the other task)
          Ironically, I think that when doing things the 'Vim Pro' way, this would get easier (but then it wouldn't useful to spot it because it is already optimal!)

  • Also, TIMTOWTDI; you can't just go and say 'here's the best way'. It depends on taste, handposition, keyboard layout, plugin availability whatnot.

  • I think by far the best way to actually learn things like this is by

    • reading documentation
    • following stack overflow [vim]

Skepticism left behind, I can see a good market for a plugin with hint-like features:

I'd be thinking 'always-on' hints, much like you see in cheesy chess engines (showing reachable fields, attacked fields, risks, skewers, forks and a visualization of the outcome of an exchange combination):

  • You could show the position of markers in the margin (so people will become more aware of them, especially <,> and such). A plugin that does this now is ShowMarks: in the screenshot, note the marks for a and b, but also (nifty!) the locations for the { and ( and similar text motions (I've seen >, . and others just now). 1

    Productivity analyzer for vim

  • :set relativenumber is already helpful in making users think of 13j instead of jjjjjjjjjjjjj - but see my preference here Moving the point between in charactors by quick search

  • I could see syntax highlighting plugin happen where enclosing textobjects (word, WORD, sentence, paragraph or identifier, parenblock, braceblock) would be highlighted in increasing shades of the background color. If we think of a way of overlaying a helpful hint (which key to use for the text object motion), you'd get very good hinting, IMO.

  • I could see a hint for pressing 'o' to move the cursor to the other end of a visual selection

  • the standard matchit is already quite instrumental in hinting about matching brackets (although it doesn't hint in actual clippy style that you might use % to get there)

  • other inspiring uses of the +signs feature are: errormarker.vim (which uses balloon tips in addition to placing a graphical sign); I can see this being put to good use (if only to point at certain documentation topics)

    Productivity analyzer for vim

Regarding the text object highlighter, I suspect it might already exist. I'm going to have a look now


1 I think to get more marks, I needed to do (?)

 :let g:showmarks_include+="<>[]"
 :ShowMarksOn

I also recommend setting updatime to something quick (say, 500ms)


I find your idea very interesting. With the right tone, such a feature would probably be helpful and not only for newbies.

But I see a bunch of difficulties:

  • Would you show "the right way" to perform the previous task or a shorter way without regard for its correctness? For example, a new Vim user could do Vjjjd to delete 4 lines, do you propose V3jd or 4dd or maybe dip if suitable or whatever other solution?
  • How would you define "the right way" anyway? By consensus here on SO or on some mailing list or by asking to a group of reputable Vim experts?
  • How would you define the task you are analysing? What are the boundaries for a task?

Whatever, this is a neat idea.


My personal opinion on this is, that a clippy like tool is very difficult to handle. As people mentioned above I think the most difficult part about it is to understand the users intentions when writing text. If you put that away and have a clear way of adding semantics to your intentions your life could become a lot easier!

So instead of live suggestions I guess as a first step an input-output-sequence workflow could be easier to test and get results from.

I was thinking about programming a generalized vi front end to apply it to all kinds of editors/text boxes (i.e.: pidgin).

One of the results of this thought process is, that the input language should be somewhat regular (or context free at most). hence the input of a vi instance can be represented by a state machine. This is not fully proven, but rather a vague guess! Clearly more effort has to be put into whether the repetition commands (e.g.: 13j) might not get the language into context free grammars.

If the vi input language is regular you might get a chance to use bounded model-checking to compute a sequence of state transitions in that state graph that result in your required output. I think currently the most potent ways to do bounded model checking is via counterexamples and reducing the problem to a sat instance (just google for it).

I would like to hear your opinion on this, so please comment and if there is anything more involved we can try to chat about this.

edit

i think you can try to do standard optimizer work that compilers do.

however not that especially macros q[a-z] @[a-z] might be hard to find and replace. I would assume, that this is NP complete.

0

精彩评论

暂无评论...
验证码 换一张
取 消