Add Your Vimrc to Obsidian
Tags: vim, obsidian
Published: 2022-03-22 02:03:33

---
title: Add Your Vimrc to Obsidian
published: true
date:
tags: vim, obsidian 
canonical_url: https://nickymarino.com/2021/12/21/add-vimrc-to-obsidian/
---

I’ve migrated my note taking system from [Craft](https://www.craft.do) to [Obsidian](https://www.craft.do) over the past few weeks, and it’s been great so far. One major advantage of Obsidian is its amazing developer community and wide, wide universe of [community plugins](https://obsidian.md/plugins). I use quite a few community plugins:

![My community plugins](https://nickymarino.com/public/assets/2021/add-vimrc-to-obsidian/img1.png)

One of my favorite features of Obsidian is its support for vim bindings. I use vim and VS Code’s vim bindings all the time, and I’m able to context switch much faster between coding and note writing when all of my editors use vim keys.<sup id="fnref:google-docs" role="doc-noteref"><a href="#fn:google-docs" rel="footnote">1</a></sup>

You can turn on vim bindings in your own Obsidian vault by going to “Settings” > “Editor” and toggling “Vim key bindings”:

![Enable vim bindings](https://nickymarino.com/public/assets/2021/add-vimrc-to-obsidian/img2.png)

The only downside to Obsidian’s default vim bindings is the lack of `.vimrc` support out of the box. My personal `.vimrc` has a few shortcuts that I rely on:

- I map `;` to `:` in normal mode so that I don’t rely on the shift key
- I map `j` to `gj` (and `k` to `gk`) to jump by visual lines instead of logical lines by default

The `;` mapping isn’t a deal breaker in Obsidian; I’m not using vim commands that often. However, the `j` and `k` remaps are critical! Obsidian wraps text much more than a terminal thanks to its generous padding. Even on this “simple” post with just a lot of text, one line turns into four in Obsidian:

![Long text line example](https://nickymarino.com/public/assets/2021/add-vimrc-to-obsidian/img3.png)

Luckily, there’s plugin for Obsidian `.vimrc` files: [Obsidian Vimrc Support Plugin](https://github.com/esm7/obsidian-vimrc-support). To add this to your Obsidian vault, go to “Settings” > “Community plugins” > “Browse” and search for “vimrc”:

![Searching for vimrc plugin](https://nickymarino.com/public/assets/2021/add-vimrc-to-obsidian/img4.png)

Then click “Vimrc Support”, “Install” and “Enable”:

![Enabling vimrc support plugin](https://nickymarino.com/public/assets/2021/add-vimrc-to-obsidian/img5.png)

At the root of your Obsidian vault (the root folder for all of your `.md` files), create a new file named `.obsidian.vimrc`. You can paste any of your `~/.vimrc` into your `.obsidian.vimrc`.

Here’s my `.obsidian.vimrc` that remaps `;`, `j`, and `k` in normal mode:

```
" .obsidian.vimrc
"
" A small .vimrc for Obsidian vim bindings
"
" To enable this file, you must install the Vimrc Support plugin for Obsidian:
" https://github.com/esm7/obsidian-vimrc-support
" _________________________________________________________________________

" ; (semicolon) - same as : (colon)
nmap ; :

" (space) - same as : (colon)
nmap <SPACE> :

" j and k navigate visual lines rather than logical ones
nmap j gj
nmap k gk

```

Once you write your `.obsidian.vimrc`, reload Obsidian and your new vim bindings will load!

1. The only downside is that I start typing gibberish whenever I open Google Docs or Word, but that’s a sacrifice I’m willing to make. [↩](#fnref:google-docs)