Or, “So I started reading Dr. Drang…”
One of the things I’m fairly obsessive about is refining my various workflows. One of the best sources of fun new tips for doing so that I’ve found in a while (or forever, really) is Dr. Drang’s blog (which I was directed to via one of Merlin Mann’s recent podcasts).
Reading through the archives of the good doctor, I’ve been inspired to start taking more advantage of TextExpander, (multi)markdown, and the intersection thereof. This coincides well with my recent switch from Emacs to Vim, with the reversion to the Unix philosophy of using many small, sharp tools. While on Emacs, I’d typically use Org-Mode for writing everything, I’ve been trying to find a nice replacement that doesn’t rely on that monolith of software. I’m very happy with multimarkdown (especially as of version 3.0, which I’m finding to be much more robust (especially for LaTeX output (good-bye XSLT!))), and TextExpander is great (especially with Applescript snippets)…although it does have some issues with MacVim, a player can roll.
The other little tweak I’ve been using is using Notational Velocity (well, nvAlt) for my writing instead of filesystem folders for much of my new stuff. This way I get nice synchronization, easy search, and with a utility like QuickCursor, I can still edit with vim no problem.
Aside
In a recent Back to Work episode, Merlin talks about how he thinks “inspiration” is an essentially phony concept, asking what anyone has ever done because of “inspiration”. Well, this isn’t exactly the Mona Lisa, but reading Dr. Drang inspired me to start using TextExpander and Markdown more, which is why I’m writing this particular entry, to test out some new snippets and Vim functions.
Bonus Feature!
Sadly, the TextExpander snippet I was using to insert markdown reference-style links doesn’t work properly in Vim. The upside of that though, is that I got a good excuse to muck about with vimscript to write a replacement. Et voilà:
vimscript:
1: " Insert markdown reference-style link
2: function! AddMarkdownReferenceLink() " {{
3: call inputsave()
4: let refLink = input("Reference label: ")
5: call inputrestore()
6: exe "normal f]a[".refLink."]"
7: let l = line(".")
8: let c = col(".")
9: normal Go
10: " TODO: Make this cross-platform?
11: .!pbpaste
12: exe "normal >>I[".refLink."]: "
13: call cursor(l, c)
14: endfunction
16: autocmd FileType markdown nmap <buffer> <leader>[ ysiw]:call AddMarkdownReferenceLink()<CR>
17: autocmd FileType markdown vmap <buffer> <leader>[ S]:call AddMarkdownReferenceLink()<CR>
18: autocmd FileType markdown imap <buffer> <C-l> <Esc>b<leader>[a
The net effect of this is that you can hit <leader>[ in normal or visual mode
or ⌃-l in insert mode to turn a word (or selection) into a reference link,
with the link placed at the bottom of the page. The function will ask you what
you want the reference to be and will put whatever you have in your
clipboard as the link (for those that don’t know, pbpaste is a nifty little
command line utility that echoes out the current clipboard; along with it’s
sister pbcopy you can do some pretty nifty tricks).
You can see a demo of it’s usage below and see my vimrc (and some other stuff) in its entirety at my github.
Vim markdown reference links from James Cash on Vimeo.