Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Productivity analyzer for vim

Tags:

text

vim

analysis

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 sense and is there any theory covering such analysis?

like image 776
wik Avatar asked Oct 12 '11 04:10

wik


2 Answers

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

    enter image description here

  • :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) enter image description here

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)

like image 181
sehe Avatar answered Nov 16 '22 01:11

sehe


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.

like image 45
romainl Avatar answered Nov 16 '22 01:11

romainl