Vim in Obsidian

Though using vim in Obsidian Rules is not as smooth as using vim in Neovim, it’s okay for focused writing. Using vim in Obsidian helps focus more on writing with the keyboard, without needing to move the mouse. However, it has limitations because it integrates even less functionality from vim compared with vim in VSCode.

Obsidian Vimrc Configuration

Create a .obsidian.vimrc file:

" Visual line navigation
noremap j gj
noremap k gk
noremap gj j
noremap gk k
 
" Clear highlights
nmap <F5> :nohl
 
" Tab navigation (emulate gt and gT)
exmap nextTab obcommand workspace:next-tab
exmap prevTab obcommand workspace:previous-tab
nmap gt :nextTab
nmap gT :prevTab
 
" Folding commands
exmap unfoldall obcommand editor:unfold-all
exmap togglefold obcommand editor:toggle-fold
exmap foldall obcommand editor:fold-all
exmap foldless obcommand editor:fold-less
exmap foldmore obcommand editor:fold-more
nmap zo :togglefold
nmap zc :togglefold
nmap za :togglefold
nmap zm :foldmore
nmap zM :foldall
nmap zr :foldless
nmap zR :unfoldall
 
" Spell check
exmap contextMenu obcommand editor:context-menu
nmap z= :contextMenu
vmap z= :contextMenu
 
" Exit commands
exmap wq obcommand workspace:close
exmap q obcommand workspace:close
 
" Window navigation
exmap focusRight obcommand editor:focus-right
nmap <C-w>l :focusRight
 
exmap focusLeft obcommand editor:focus-left
nmap <C-w>h :focusLeft
 
exmap focusTop obcommand editor:focus-top
nmap <C-w>k :focusTop
 
exmap focusBottom obcommand editor:focus-bottom
nmap <C-w>j :focusBottom
 
" Window splitting
exmap vsplit obcommand workspace:split-vertical
nmap <C-w>v :vsplit
 
exmap split obcommand workspace:split-horizontal
nmap <C-w>s :split
 
" Yank to system clipboard
set clipboard=unnamed
set tabstop=4

Source: Obsidian - Paul’s Notes