For some time I've been searching for a plugin that would allow me to take notes without any hassle. I enjoy using markdown, so naturally this plugin had to support that format.
Recently I came across vimwiki. It has almost everything that I wanted, although there are a couple of flaws. But since it's vim it is very easy to fix them yourself.
Installing vimwiki
If you're using vim-plug, you can install it simply by adding following in your ~/.vimrc file:
call plug#begin()
Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
call plug#end()
I recommend using dev branch as I found it to be pretty stable, with a lot of bugfixes.
Using vimwiki
vimwiki supports wiki format as well as markdown but since our task is to use the latter we need to add following to ~/.vimrc:
let g:vimwiki_list = [{ 'path': '~/Documents/notes/',
\ 'syntax':'markdown', 'ext': '.md' }]
This will tell the plugin that all notes must be stored in ~/Documents/notes/, which is compatible with most OS and you will profit automatically of iCloud sync in MacOS. It also tells that we are using markdown format by default and our default root note will be called index.md. To access this note you need to hit Leader + w + w from any vim buffer.
After you've opened any note you can hit Enter on any word or selection and vimwiki will create a link to a child note(with that word or selection as a name) and the note file itself. Once the link is created you can simply navigate to a child note by hitting Enter once again. Magic!
The flaws and how to fix them
The main flaw is that vimwiki replaces itself as syntax highlighter for markdown files. Compare:
vimwiki highlight

to vim-markdown highlight

I know that it depends on colorscheme, but I saw same result on multiple variants.
The second flaw is it changes filetype to vimwiki so that you lose all your snippets and other good stuff that was linked to markdown filetype.
To fix both you need to add following line to ~/.vimrc:
autocmd FileType vimwiki set ft=markdown
That way we reset the vimwiki file type to markdown, all the magic functionality that I talked about earlier will remain.
You can find all the configuration in my vim settings repo:
Vim Settings
An article describing key features of this config.
Prerequisites
In order to get all features you might want to install following packages:
Installation
On unix and windows(with bash which can be installed with git):
curl -L https://raw.github.com/gko/vimio/main/install.sh | bash
macOS
In macOS terminal.app don't forget to check the «Use option as meta key»:
And «Esc+» option in iterm2:
Shortcuts
Some of shortcuts(Leader key is comma):
- Ctrl + s saves current file
-
Leader + s in both
selectandnormalmode initiates search and replace - Alt + Up/Down moves line or selection above or below current line(see upside-down for more info)
- Alt + Left/Right moves character or selection to left or to the right
- Leader + n toggles NERDTree
- Leader + m shows current file in NERDTree
- when in select mode ', ", ( wraps selection accordingly
- y…
I'm also on twitter as konstantin



Top comments (0)