Live data from Hacker News

VimGolf.com - real Vim ninjas count every keystroke

vimgolf.com

51–60 of 86 posts

Re: VimGolf.com - real Vim ninjas count every keystroke

#51
post #38

Any tips on improving 'Sort and add attributes'? I have scored 38 with: :sor :%s/)/, :country => "USA")/

:sor|%s/)/, :country => "USA") works for me

This shaves off a few chars: a) combining the commands b) leaving off the last / in the search/replace

Re: VimGolf.com - real Vim ninjas count every keystroke

#52

I held the title on "Brackets or Braces?" [0] for a good seven minutes with a 44 character solution [1], only to be ousted by @ryanmusicman with 42. Can anyone see an obvious way to improve mine? [0]: http://vimgolf.com/challenges/4d1a522ea860b7447200010b [1]: https://gist.github.com/757767

A quick thought: use surround.vim plugin for this.

Re: VimGolf.com - real Vim ninjas count every keystroke

#53

Earlier quoted context omitted.

Awesome! You are currently the winner!

To be fair, I borrowed from a couple others here, but that was generally the approach I had in mind. Of course, we aren't genuinely doing what the author intended. The point was not to copy-paste the line, but actually to perform what would be rather typical edits. I also was rather lucky that the file happened to be structured such that "3j" put the cursor in the right place each time. It's also not clear whether or…

As the scoring currently stands, it doesn't seem to count shift presses. It does count escapes though.

Re: VimGolf.com - real Vim ninjas count every keystroke

#54
post #52

I held the title on "Brackets or Braces?" [0] for a good seven minutes with a 44 character solution [1], only to be ousted by @ryanmusicman with 42. Can anyone see an obvious way to improve mine? [0]: http://vimgolf.com/challenges/4d1a522ea860b7447200010b [1]: https://gist.github.com/757767

A quick thought: use surround.vim plugin for this.

Sadly, that's not allowed :(

Re: VimGolf.com - real Vim ninjas count every keystroke

#55
post #48

You should really make some challenges that require the users to pass multiple tests with the same script. Sure, you can solve the reformat/refactor challenge by jd2jVjj=f(ci)*a^]jcfda.join(',')^] but it wont generalize anywhere. Having a full script though that will detect and do that automagically, now there's the fun part.

    4JD=Gjwci(*a^]jcfda.join(',')^]
God this is addicting. Shaved off a few characters.

edit: switch the first three letters to j3D, as 4JD seems to work differently between my two machines.

Re: VimGolf.com - real Vim ninjas count every keystroke

#56
post #28

Until somebody can come up with at least some method of restricting vim scripting, the results are useless(one can easily only use 4 key strokes by key mapping as you can see). But, on the other hand, you can't just disable vim from loading scripts, because there's no point in mastering the plain old vim without any plugins, custom key mappings and such.

I've been trying with editing the file in another editor, then :e! :wq which seems to give 17/18 score mostly. I love this idea and love the challenge, but would love to make it less hackable as well.

ZZ instead of :wq will knock a letter off. I'm guessing that's what the current leader with 16 is doing on this challenge: http://vimgolf.com/challenges/4d1a1c36567bac34a9000002

Re: VimGolf.com - real Vim ninjas count every keystroke

#57
post #2

Where are the solutions? That's the fun thing about Perl golf is seeing how people did it in X characters. Without solutions...well, I don't see the point.

I'm logging the solutions, but in real MVP fashion... not showing them just yet. Need to bootstrap a vimscript parser first. If anyone is up for it, would love some help with the client/parser: https://github.com/igrigorik/vimgolf

Do you really need to do anything super smart with them? Could you at least link to the logged scripts as files? Smarter stuff can come later.
Post reply on HN