< Return to Video

Emacs Rocks! Episode 02: A vimgolf eagle

  • 0:00 - 0:03
    Hi! Welcome back to Emacs rocks!
  • 0:03 - 0:08
    It's episode 2 and today I have a real treat for you. Check it out!
  • 0:08 - 0:11
    It's VimGolf! Yay!
  • 0:12 - 0:16
    VimGolf is really cool, I really wish there was one for Emacs.
  • 0:17 - 0:21
    It's a competition and the goal is to transform
  • 0:21 - 0:24
    the starting file into the ending file
  • 0:24 - 0:27
    in as few keystrokes as possible.
  • 0:30 - 0:33
    So, this is challenge number 6 and
  • 0:33 - 0:39
    there is a one to ten in letters and a one to ten in numbers
  • 0:39 - 0:44
    and the goal is to get the one to ten lined up in two columns.
  • 0:45 - 0:50
    So the best score into Vim is 17, is the winning score.
  • 0:51 - 0:54
    So let's see if Emacs might do a little bit better.
  • 1:13 - 1:17
    Ok, I'll run through it one time without commentary
  • 1:17 - 1:20
    and then I'll run through it again and tell you what I'm doing.
  • 1:20 - 1:23
    So pay attention to the keystrokes.
  • 1:46 - 1:50
    Haha! Now wasn't that awesome.
  • 1:50 - 1:53
    Let's see it again in slow motion.
  • 2:02 - 2:04
    Ok, now we are back to the start.
  • 2:05 - 2:09
    This is the first episode where I use macros but it won't be the last!
  • 2:09 - 2:12
    Macros is a powerhorse in Emacs.
  • 2:12 - 2:16
    So I start by defining a macro pressing F3
  • 2:16 - 2:22
    then jump to the bottom and I delete all.
  • 2:22 - 2:27
    This puts it into the kill ring and I erase the space
  • 2:27 - 2:30
    and then I press Control-9
  • 2:30 - 2:33
    Control-9 doesn't do anything on it's own,
  • 2:33 - 2:36
    but it makes my next command repeat 9 times.
  • 2:37 - 2:42
    Which is command p for previous line, 9 lines up
  • 2:42 - 2:49
    Control-E, tab, yank, and my macro is finished.
  • 2:49 - 2:52
    So I press F4 to complete my macro and now
  • 2:52 - 2:58
    I can run that macro nine times, Control-9 F4.
  • 2:58 - 3:00
    Done.
  • 3:00 - 3:03
    And that was 12 keystrokes.
  • 3:03 - 3:07
    Let me remind tou, best in Vim, 17.
  • 3:07 - 3:10
    So, to reiterate
  • 3:12 - 3:15
    Emacs rocks!
Title:
Emacs Rocks! Episode 02: A vimgolf eagle
Description:

http://emacsrocks.com - Rocking emacs tricks and tips screencast.

Follow me on twitter: @emacsrocks

more » « less
Video Language:
English
Duration:
03:15
mukik182 added a translation

English subtitles

Revisions