Using Neovim as a Zettelkasten
One-liners for accessing text files as if they were digital notecards
I’ve started maintaining a Zettelkasten. This is a big collection of interlinked notes, traditionally maintained by hand on notecards. I’m building my digitally, as a big flat directory full of .md files.
I’m not the only person who’s tried this so there are a bunch of different Neovim plugins for it. I’m using Furkanzmc/zettelkasten.nvim and I’m largely just using one command from it, :ZkNew
, to create a new note with the timestamp as the title. Then I write out the links to other notes by hand. The plugin then makes it possible to use gf
to follow note links.
The main downside to doing this instead of using notecards is that I don’t have the physical affordances of notecards. I can’t idly page through them and I can’t shuffle them. This is a big part of the point of a Zettelkasten. You take your notes and you develop them over time. The fact that they’re physically note cards helps you see them in new ways. The tendency with digital notes is to just look at them in the same order over and over again.
Happily though I’ve got the full power of the GNU coreutils on tap, so I don’t need to write very much software in order to access text files however I want.
So I can open a random note.
nvim $(ls | shuf -n 1)
And then spend some time thinking about whatever my random number generator has presented to me, follow the links to the notes it’s connected to, and have some thoughts I might not otherwise have had just starting in my Zettelkasten the way I’ve gotten into the habit of starting.
I can also open the note I haven’t touched in the longest.
nvim $(ls -1tr | head -1)
This usually brings me to a part of the Zettelkasten I haven’t looked at for a while, which is also good for waking up the brain cells.
I can also open a note that doesn’t have any links.
nvim $(grep -Lr "\[\[" * | head --lines 1)
Usually when I add a note I start with a link, but sometimes I’m just jotting something down and I haven’t decided how it relates to the rest of the Zettelkasten. When I want to work on it a bit but don’t have anywhere better to start, linking something in is usually a good place to start.
I’d also like to write a command that opens a random note that only has one link, but that’s a slightly more complex grep-type command.