Skip to content

Instantly share code, notes, and snippets.

@Keshav13142
Last active June 3, 2024 05:13
Show Gist options
  • Save Keshav13142/81859c5d2691c76aa56d3f421534219e to your computer and use it in GitHub Desktop.
Save Keshav13142/81859c5d2691c76aa56d3f421534219e to your computer and use it in GitHub Desktop.
obsidian-vimrc
" Have j and k navigate visual lines rather than logical ones
nmap j gj
nmap k gk
" Go to beginning/end of line
nmap gh ^
nmap gl $
" Cycle between tabs
exmap tabprev obcommand workspace:previous-tab
nmap H :tabprev
exmap tabnext obcommand workspace:next-tab
nmap L :tabnext
" Yank to system clipboard
set clipboard=unnamed
" Focus on splits
exmap ftop obcommand editor:focus-top
nmap <C-k> :ftop
exmap fbottom obcommand editor:focus-bottom
nmap <C-j> :fbottom
exmap fleft obcommand editor:focus-left
nmap <C-h> :fleft
exmap fright obcommand editor:focus-right
nmap <C-l> :fright
" Have to unmap space to use it
unmap <Space>
" Save file
exmap save obcommand editor:save-file
nmap <Space>w :save
" Go to link
exmap follow obcommand editor:follow-link
nmap gd :follow
" Rename title
exmap rename obcommand workspace:edit-file-title
nmap <Space>r :rename
" Insert templates
exmap ins_temp obcommand templater-obsidian:insert-templater
nmap <Space>t :ins_temp
" Toggle zen mode
exmap zen obcommand obsidian-prozen:zenmode
nmap <Space>z :zen
" Toggle file explorer
exmap tleftbar obcommand app:toggle-left-sidebar
nmap <Space>e :tleftbar
" Toggle calendar
exmap trightbar obcommand app:toggle-right-sidebar
nmap <Space>E :trightbar
" Open today's note
exmap daily obcommand daily-notes
nmap <Space>d :daily
" Open cmd palette
exmap cmd obcommand command-palette:open
nmap <Space>sc :cmd
" Open file search
exmap fileSearch obcommand switcher:open
nmap <Space>sf :fileSearch
" Focus on global search input
exmap globalSearch obcommand global-search:open
nmap <Space>sg :globalSearch
" Close current tab
exmap close obcommand workspace:close
nmap <Space>c :close
" Paste into selection (for creating links)
map <Space>p :pasteinto
" Quickly remove search highlights
nmap <Space>h :nohl
" Splits
exmap vsplit obcommand workspace:split-vertical
nmap <Space>v :vsplit
exmap hsplit obcommand workspace:split-horizontal
nmap <Space>V :hsplit
" 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 { }
map [[ :surround_wiki
nunmap s
vunmap s
map s" :surround_double_quotes
map s' :surround_single_quotes
map s` :surround_backticks
map sb :surround_brackets
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
@Keshav13142
Copy link
Author

Keshav13142 commented Jul 20, 2023

General overview :

  • Install the vimrc support community plugin and enable it.
  • Create a .obsidian.vimrc file in the root of your vault.
  • Paste the contents of this gist in it. ( Note: Some keymaps require their respective plugins to be installed )
  • Customize it and enjoy a superior editing expereince.

To check for all available commands type :obcommand and look at the output in the developer console ( Ctrl + Shift + i )

Note : If you have same keys bound to some action in both your obsidian hotkeys and vimrc, then remove the hotkeys using the obsidian settings

Inspired from here

@Syphdias
Copy link

:110 should be map s] :surround_square_brackets

@Keshav13142
Copy link
Author

:110 should be map s] :surround_square_brackets

Thank you, I just fixed it!

@eugeny-dementev
Copy link

Saw your link to that config while watching ThePrimeagen Obsidian. Real nice config you have here. Found a lot of useful things to improve my Obsidian experience. Big thanks!

@megamind1230
Copy link

saw your goofy link too on theprimeagen video .. but seriously .. this is exactly what I needed .. Huge hug and thanks for you bro.. made my day

@Keshav13142
Copy link
Author

Glad you guys are finding it useful ;). I sent the link from my phone that why it was messed up haha. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment