WEBVTT 00:00:00.000 --> 00:00:03.436 Hi! Welcome back to Emacs rocks! 00:00:03.436 --> 00:00:08.125 It's episode 2 and today I have a real treat for you. Check it out! 00:00:08.125 --> 00:00:10.562 It's VimGolf! Yay! 00:00:11.900 --> 00:00:15.925 VimGolf is really cool, I really wish there was one for Emacs. 00:00:17.292 --> 00:00:21.371 It's a competition and the goal is to transform 00:00:21.387 --> 00:00:23.662 the starting file into the ending file 00:00:23.662 --> 00:00:26.800 in as few keystrokes as possible. 00:00:29.508 --> 00:00:33.244 So, this is challenge number 6 and 00:00:33.244 --> 00:00:39.152 there is a one to ten in letters and a one to ten in numbers 00:00:39.152 --> 00:00:43.923 and the goal is to get the one to ten lined up in two columns. 00:00:45.382 --> 00:00:49.790 So the best score into Vim is 17, is the winning score. 00:00:51.052 --> 00:00:54.233 So let's see if Emacs might do a little bit better. 00:01:12.833 --> 00:01:17.005 Ok, I'll run through it one time without commentary 00:01:17.021 --> 00:01:20.259 and then I'll run through it again and tell you what I'm doing. 00:01:20.259 --> 00:01:22.789 So pay attention to the keystrokes. 00:01:46.000 --> 00:01:49.825 Haha! Now wasn't that awesome. 00:01:50.008 --> 00:01:53.167 Let's see it again in slow motion. 00:02:01.621 --> 00:02:04.246 Ok, now we are back to the start. 00:02:04.938 --> 00:02:09.282 This is the first episode where I use macros but it won't be the last! 00:02:09.282 --> 00:02:12.413 Macros is a powerhorse in Emacs. 00:02:12.413 --> 00:02:15.656 So I start by defining a macro pressing F3 00:02:15.656 --> 00:02:21.887 then jump to the bottom and I delete all. 00:02:22.385 --> 00:02:27.429 This puts it into the kill ring and I erase the space 00:02:27.429 --> 00:02:30.136 and then I press Control-9 00:02:30.136 --> 00:02:32.690 Control-9 doesn't do anything on it's own, 00:02:32.690 --> 00:02:35.675 but it makes my next command repeat 9 times. 00:02:36.775 --> 00:02:41.931 Which is command p for previous line, 9 lines up 00:02:42.498 --> 00:02:48.579 Control-E, tab, yank, and my macro is finished. 00:02:48.579 --> 00:02:52.175 So I press F4 to complete my macro and now 00:02:52.175 --> 00:02:57.631 I can run that macro nine times, Control-9 F4. 00:02:58.467 --> 00:03:00.105 Done. 00:03:00.105 --> 00:03:03.008 And that was 12 keystrokes. 00:03:03.008 --> 00:03:06.748 Let me remind tou, best in Vim, 17. 00:03:07.485 --> 00:03:09.944 So, to reiterate 00:03:11.621 --> 00:03:14.525 Emacs rocks!