" Custom Commands "---------------- command! Vimrc edit $MYVIMRC " Edit .vimrc (this file) command! Refresh source $MYVIMRC " Refresh from .vimrc (this file) command! Today exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md' " Custom Keybinds "---------------- " Map the leader key map " Unsets the search pattern register by hitting return nnoremap :noh " Shuffle lines around nnoremap :m .+1== nnoremap :m .-2== inoremap :m .+1==gi inoremap :m .-2==gi vnoremap :m '>+1gv=gv vnoremap :m '<-2gv=gv " Jump to text in this directory nnoremap / :Rg " Quit vim nnoremap q :quit nnoremap Q :quitall " Save file nnoremap fs :write " Make file executable nnoremap fe :!chmod 755 % " Make file normal permissions nnoremap fn :!chmod 644 % " Open file in this directory nnoremap ff :Files " Change directory to this file nnoremap fd :lcd %:p:h " Back up directory nnoremap fu :lcd .. " Open a recent file nnoremap fr :History " Switch between multiple open files nnoremap b :Buffers " Switch between two open files nnoremap :b# " Jump to text in this file nnoremap s :BLines " Toggle Git gutter (by line numbers) nnoremap ` :GitGutterToggle " Git repo nnoremap gr :!gh repo view -w " Split window nnoremap wv :vsplit nnoremap wh :split " Close all other splits nnoremap wm :only " Jump around nnoremap :HopWord " Zoom / Restore window. " https://stackoverflow.com/a/26551079 function! s:ZoomToggle() abort if exists('t:zoomed') && t:zoomed execute t:zoom_winrestcmd let t:zoomed = 0 else let t:zoom_winrestcmd = winrestcmd() resize vertical resize let t:zoomed = 1 endif endfunction command! ZoomToggle call s:ZoomToggle() nnoremap z :ZoomToggle " Exit terminal mode tnoremap " Reload Vimrc settings nnoremap rr :Refresh nnoremap rp :Refresh :PlugInstall " Tabularize noremap ta :Tabularize / noremap t# :Tabularize /# noremap t" :Tabularize /" " Read todo comments nnoremap td /# \?TODO:\?