We haven’t had an EmacsGolf challenge for a while so here’s something simple that was suggested by Xah Lee based on a Stack Overflow question. The Stack Overflow questioner wanted a solution in Vim so the whole thing fits right in with our never ending quest to solve problems more efficiently in Emacs. The best answer at Stack Overflow using Vim was 53 keystrokes. Let’s see if we can beat that.
The starting buffer is 10 lines each beginning with a time in minutes:seconds as shown.
05:16 more line 1 text 06:32 more line 2 text 13:50 more line 3 text 27:36 more line 4 text 33:07 more line 5 text 33:12 more line 6 text 41:03 more line 7 text 48:22 more line 8 text 51:05 more line 9 text 57:58 more line 10 text
We want to change the time into seconds
316 more line 1 text 392 more line 2 text 830 more line 3 text 1656 more line 4 text 1987 more line 5 text 1992 more line 6 text 2463 more line 7 text 2902 more line 8 text 3065 more line 9 text 3478 more line 10 text
There are a couple of ways of doing this. One uses query-replace-regexp
and works with stock Emacs. The other uses Magnar Sveen’s terrific multiple cursors in a way similar to his last example in the multiple cursors video. Using multiple cursors takes me 22 keystrokes. Can you do better?