Arc Forumnew | comments | leaders | submitlogin
2 points by rocketnia 3951 days ago | link | parent

"This idea has something in common with IDEs that highlight all occurrences of the word at the cursor."

This is a feature I miss when I can't have it. I bet this highlighting would really help when reading printed-out code or code examples on a blog.

---

Your approach isn't semantic, in the sense that it doesn't discriminate between similarly named variables based on the language's actual scoping rules, but I wouldn't worry about that too much. When I name two variables the same thing, they usually are related in some way. Sometimes they all hold the same value most of the time, or sometimes they all have the same syntactic significance (e.g. CPS callbacks), or if all else fails... they have the same name. ^_- If it annoys me that they're highlighted the same way, it probably also annoys me that they have the same name.

---

You may also be interested to know that Nulan (well, the last stable version of Nulan) highlights variables differently depending on whether they're macros, locals, or non-macro globals.



1 point by akkartik 3951 days ago | link

Yeah I've run into this already. In the screenshot for my original solution I highlighted a variable called test. Oops, poor name. Trouble is that this change now causes poor names in tightly localized contexts to bleed through the entire codebase :/

There's two directions to solve this:

a) Automatically detect variables with long lifetimes (measured in lines) to highlight. Perhaps this is a refinement of highlighting for

  *globals*
b) A way to attach metadata on a per-function or per-fragment basis. Highlight test in this function but not elsewhere, etc.

-----

1 point by akkartik 3951 days ago | link

Heh, I just thought of a name for the plugin that turns the bug into a feature: synaesthesia.vim :)

-----

2 points by rocketnia 3951 days ago | link

There was some interesting discussion on that in the Reddit thread. :)

-----

2 points by akkartik 3950 days ago | link

You got me, that's where I stole the idea from.

-----