Skip to content

Instantly share code, notes, and snippets.

@iceadobe
Last active June 22, 2024 15:36
Show Gist options
  • Save iceadobe/5ff49edc10dfd272ff98937d9072de80 to your computer and use it in GitHub Desktop.
Save iceadobe/5ff49edc10dfd272ff98937d9072de80 to your computer and use it in GitHub Desktop.
Obsidian vimrc keymappings
""""""""""""""""""""""""""""
" Global Options and Configuration
""""""""""""""""""""""""""""
set clipboard=unnamed
nmap <Esc><Esc> :nohl
" important to use <Space> as a leader key
unmap <Space>
""""""""""""""""""""""""""""
" Navigation
""""""""""""""""""""""""""""
exmap back obcommand app:go-back
exmap forward obcommand app:go-forward
exmap tabnext obcommand workspace:next-tab
exmap tabprev obcommand workspace:previous-tab
exmap followLink obcommand editor:follow-link
" navigate visual lines instead
nmap j gj
nmap k gk
nmap gf :followLink
" for compatibility with vimium browser extension
nmap J :tabprev
nmap K :tabnext
nmap H :back
nmap L :forward
""""""""""""""""""""""""""""
" File Management
""""""""""""""""""""""""""""
exmap fileSave obcommand editor:save-file
exmap fileDelete obcommand app:delete-file
exmap fileMove obcommand file-explorer:move-file
exmap fileRename obcommand workspace:edit-file-title
exmap fileClose obcommand workspace:close
exmap fileOutline obcommand outline:open-for-current
exmap reopenFileClosed obcommand workspace:undo-close-pane
nmap <Space>W :fileSave
"nmap <Space>D :fileDelete "at your own risk, one tip is to enable trash
nmap <Space>R :fileRename
nmap <Space>M :fileMove
nmap <Space>X :fileClose
nmap <Space>O :fileOutline
nmap X :reopenFileClosed
""""""""""""""""""""""""""""
" Windows and Pane Management
""""""""""""""""""""""""""""
exmap vsplit obcommand workspace:split-vertical
exmap hsplit obcommand workspace:split-horizontal
exmap toggleRightSidebar obcommand app:toggle-right-sidebar
exmap toggleLeftSidebar obcommand app:toggle-left-sidebar
exmap moveToLeftWindow obcommand editor:focus-left
exmap moveToRightWindow obcommand editor:focus-right
exmap moveToBottomWindow obcommand editor:focus-bottom
exmap moveToTopWindow obcommand editor:focus-top
nmap <Space>sv :vsplit
nmap <Space>sh :hsplit
nmap <C-h> :moveToLeftWindow
nmap <C-l> :moveToRightWindow
nmap <C-j> :moveToBottomWindow
nmap <C-k> :moveToTopWindow
noremap <Space>H :toggleLeftSidebar
noremap <Space>L :toggleRightSidebar
"""""""""""""""""""
" Editor (Markdown)
"""""""""""""""""""
exmap italics surround * *
exmap bold surround ** **
exmap strikethrough surround ~ ~
exmap highlight surround == ==
map si :italics
map sh :highlight
map sb :bold
map ss :strikethrough
""""""""""""""""""
" Editor (Folding)
""""""""""""""""""
exmap togglefold obcommand editor:toggle-fold
exmap unfoldall obcommand editor:unfold-all
exmap foldall obcommand editor:fold-all
nmap za :togglefold
nmap zR :unfoldall
nmap zM :foldall
"""""""""""""""""""
" Editor (Surround)
"""""""""""""""""""
exmap surround_wiki surround [[ ]]
exmap surround_double_quotes surround " "
exmap surround_single_quotes surround ' '
exmap surround_backticks surround ` `
exmap surround_brackets surround ( )
exmap surround_square_brackets surround [ ]
exmap surround_curly_brackets surround { }
nunmap s
vunmap s
map [[ :surround_wiki
map s" :surround_double_quotes
map s' :surround_single_quotes
map s` :surround_backticks
map s( :surround_brackets
map s) :surround_brackets
map s[ :surround_square_brackets
map s[ :surround_square_brackets
map s{ :surround_curly_brackets
map s} :surround_curly_brackets
"""""""""""""""""""""""""""""
" Search (Telescope-inspired)
"""""""""""""""""""""""""""""
exmap fileSearch obcommand switcher:open
exmap globalSearch obcommand global-search:open
exmap fileExplorer obcommand file-explorer:open
exmap fileLocate obcommand file-explorer:reveal-active-file
exmap colorscheme obcommand theme:switch
nmap <Space>ft :globalSearch
nmap <Space>ff :fileSearch
nmap <Space>fl :fileLocate
nmap <Space>fe :fileExplorer
nmap <Space>fc :colorscheme
""""""""""""""""""""""
" App Management Stuff
""""""""""""""""""""""
exmap commandPallete obcommand command-palette:open
exmap appReload obcommand app:reload
nmap <Space>ca :commandPallete
nmap <Space>rr :appReload
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" plugin: Obsidian Linter
exmap formatFile obcommand obsidian-linter:lint-file
nmap <Space>fn :formatFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment