So, what's a long-time ViM user doing with an Emacs session running all the time? Using org-mode of course.
First a little bit of a problem statement: I forget everything. I've tried lots of different ways to solve the problem. I started with writing a TODO list at the beginning of each day. For a while I succeeded in using a Palm Pilot to keep track of everything. Next was a Google Calendar. For stuff that didn't fit in the calendar I tried to keep a personal wiki. Each method ended up in failure because it was cumbersome. Let me be clear, to me cumbersome means requires more work than typing on a keyboard.
I was pretty excited when I heard about org-mode. Look at the slogan: Your Life in Plain Text. How could that not be good? Not being a Saint in the Church of Emacs it took me a little longer to get comfortable with org-mode, but it was worth it. I'm sure my org-mode use hardly scratches the surface of what's possible, but it's been enough to keep me organized for the past year.
Here's what it took to get started. I created a directory called
~/notes and added the following to my Emacs startup files:
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) (global-set-key "\C-cl" 'org-store-link) (global-set-key "\C-ca" 'org-agenda) (global-set-key "\C-cb" 'org-iswitchb) (setq org-log-done t) (setq org-log-repeat "time") (add-hook 'org-mode-hook 'turn-on-auto-fill) (setq org-directory "~/notes") (setq org-agenda-files (file-expand-wildcards "~/notes/*.org"))
Whenever I want to record something I open up a relevant
~/notes and add entries like this:
* Chores ** Empty garbages ** Mow lawn
It's just an outline, with the number of leading
determining the level of each entry.
The only keys I really use frequently are:
C-c C-t: transition states (make this a TODO or mark it done)
C-c C-s: schedule this entry
C-c C-d: set a deadline for this entry
Tab: fold (show/hide children of this entry)
C-c a a: show the agenda for the current week
org-mode is far more customizable, but for me, that's enough. I'm
especially pleased at how easy it is just to start logging things that
happen in a meeting or adding something that I just remembered needing
to do around the house. There's almost no friction. And everything
about the entry lives in the text file. Then, with a few key presses
C-c a a) I know what my next week looks like.
I use ViM macros (aka
complex-repeat) all the time. Occasionally, I find that it would be nice to reuse one of my macros across editing sessions. Turns out it's pretty easy to save the macro. Just add a line like the following to a file that gets sourced when your file is opened by ViM (This example is from
let @h = "yypVr"
Now, whenever I open a ReStructured Text file, I can hit
@h and my macro will run.
At the BYU UUG meeting this week, Peter mentioned a great ViM trick that I've never seen before. Here's my feeble attempt to document it.
Because ViM macros are stored in registers they can be edited. This means that if you create a long macro and then realize that you forgot to send the cursor to the beginning of the line before finishing the recording, you don't have to create the entire macro again, you can just add the motion command. You use it like this:
- Start recording your macro by typing q and then the single character ([0-9a-zA-Z"] are allowed). The single character is the register your macro will be stored in.
- Enter the commands you want included in the macro.
- Type q to finish recording the macro.
- At this point you could run the macro by using @ and the register name.
- To modify the macro, move to a blank line and type "Rp replacing R with the register name of your macro. This will paste all the commands in your macro to the current line.
- After making the changes you need, save the macro by typing 0"Ry$ replacing R with the register name you want to use for the macro. The register name does not have to be the same as the original.