Make Vimwiki Open Links in Vertical Splits


Hey,

I found Andy Matuschak’s notes about taking notes (kind of meta hehe) super interesting.

But I was delighted by the interface his notes use to navigate. Go click on the link above and click on some of the links on the page to see what I mean.

So simple, yet so powerful! I didn’t know until now that I have always wanted this for my notes.

My current setup is using Vimwiki, and I am used to navigate through the links with the Enter key. But by default, it replaces the current buffer with the target page.

You can use CTRL+Enter to open the link a vertical split window but I wanted that to be the default behaviour.

So, long story short: there is no way to redefine that mapping easily. But you can disable all default mappings for links and then create the ones you want.

You can do so by adding the following to your .vimrc (or init.vim if you are using Neovim):

" Disable default mappings for links.
let g:vimwiki_key_mappings =
  \ {
  \ 'links': 0,
  \ }
" Custom mappings for links
nmap <CR> <Plug>VimwikiVSplitLink
nmap <S-CR> <Plug>VimwikiFollowLink
vmap <CR> <Plug>VimwikiNormalizeLinkVisualCR
nmap <TAB> <Plug>VimwikiNextLink
nmap <S-TAB> <Plug>VimwikiPrevLink

There are many more mappings (see here) but these are the few that I often use.

Hope this is helpful for you too! If it is, let me know by clicking the 👍 button below 😄.