Markdown Files On Disk

November 29, 2019

Like most people, I have a lot of random information that I want to keep track of: ideas, recipes, notes on things that I'm reading, projects I'm working on, etc. I used to use Evernote to store and organize all of these notes, but I got frustrated over not having more control over my notes and having to work around a bloated set of features that I wasn't using. I wanted something simple and fast that I could integrate into my existing tool set.

The simplest thing I could think of was storing my notes... in text files. On disk (well, in a Dropbox folder so that they synced across devices). Using Markdown. Not exactly revolutionary, but there are a few tools I use that make this system convenient enough to give me most of the functionality I'd want from a published app without having to hand over control of my data.

Command line tool

I wrote a command line tool to find and edit notes. It uses a fuzzy matcher against the names of all the files in my ~/notes directory.

With no flags, it opens the best-matching note in VIM.

note blog/markdown files

If I can't remember whether I have a certain note or what it's called, -s shows all the matching notes.

note -s blog/markdown

0.685 : blog/markdown files on disk.md
0.434 : blog/flow.md
0.4   : blog/jargon.md
0.357 : blog/deep-work.md
0.333 : blog/drive.md
  • -c Copies the path to the note to the clipboard.
  • -p Prints the path rather than opening it, which is useful for piping to other commands.
  • -t Opens the note in Typora instead of VIM.

Right now this script is written in Ruby, but I'm planning on rewriting it in Rust or something faster and more portable.

Desktop editing

Though I occasionally edit notes in Typora for OS X, I do most of my writing in VIM. There are a few plugins and configuration settings I use to make this more ergonomic.

  • Tagbar, tagbar-markdown, and markdown2ctags.py. These give me a sidebar with links to each header and subheader in the document, making it easier to see the structure of the note and to jump to a specific section.

  • vim-pencil for line wraps and breaks that work better for prose.
  • setlocal spell for spellcheck.
  • A ProseMode() function in my .vimrc to toggle all of these on or off. The note script automatically opens note files with ProseMode on, but I can also manually toggle it with <leader>p.
function! ProseMode(...)
  if !exists("b:proseon")
    let b:proseon = 0
  endif

  let a:prose = get(a:, 1, 0)

  if a:prose == 1 || b:proseon == 0
    call pencil#init({"wrap": "soft"})
    execute "TagbarOpen"
    setlocal spell
    let b:proseon = 1
  else
    call pencil#init({"wrap": "off"})
    execute "TagbarClose"
    setlocal nospell
    let b:proseon = 0
    execute "e"
  endif
endfunction

command! ProseMode call ProseMode()
nmap <leader>p :ProseMode<CR>

ProseMode is also great for editing README files and other Markdown content.

Mobile editing

On my phone I use Editorial to find and edit notes, but any Markdown editor that can sync with Dropbox would work.