3 ms·
I love the idea of a built-in hotkey for jumping to a random line across the entire codebase. Like a fuzzer, but for your understanding of your project. ...and
by callahad 12y ago
I love the idea of a built-in hotkey for jumping to a random line across the entire codebase. Like a fuzzer, but for your understanding of your project.
...and now I really want to write a vimscript to do the same.
- lost-theory 12y agoHere's a python one-liner that will do it: import os; import random; os.system("vim %s +%s" % (lambda f: (f, random.randint(1,len(open(f).readlines())+1)))(random.choice([f for f in sum([[os.path.join(p, f) for f in fs] for (p, ds, fs) in os.walk(".")], []) if not ".git" in f])))
- dradtke 12y agoThat's one hell of a one-liner.
- archgoon 12y agoOld math joke: "It's a one line proof; if you start far enough to the left."
- e12e 12y agoIt's a great example of the trade-offs made in python (as opposed to, say, perl) design: It's not really a one-liner (yeah, it fits on one line, but it just cries out to be re-formatted) -- it's too verbose -- but the flip side is that it's actually rather readable.
- vegggdor 12y agoHaving to use lambdas just to get the syntax to allow for a one liner makes your point about reformatting.