" Swaps semi colon to colon in normal mode nnoremap ; : nnoremap : ; " Swaps semi colon to colon in visual mode vnoremap ; : vnoremap : ; " Make jj in insert mode go to normal mode inoremap jj " Make ctrl+hjkl change focus between windows nnoremap h nnoremap j nnoremap k nnoremap l if has('clipboard') " Make Ctrl C and Ctrl V work on system clipboard " if in visual or insert mode respectively vnoremap "+y inoremap "+pa endif " Fix previous spelling mistake in insert mode " Shamelessly taken from https://castel.dev/post/lecture-notes-1/ " u - break undo sequence (new change) " - go into normal mode " [s - go to previous spelling mistake " 1z= - change to the top spelling suggestion " `] - go to the end of the last changed word " a - enter insert mode " u - break undo sequence (new change) inoremap u[s1z=`]au " Do Shebang line " - go into normal mode " :silent - run command silently " s/^/…/ - write at the begining of the line " - used to seperate commands " filetype detect - attempt to detect filetype again " :nohlsearch - un-hilight the search pattern inoremap :silent s/^/#!\/usr\/bin\/env / filetype detect:nohlsearcho " alternative: inoremap :silent exe ".!which " s/^/#!/ filetype detectYpDi " Mappings for my encoding functions vnoremap [b :call mine#encoding#wrapper('base64Encode') vnoremap ]b :call mine#encoding#wrapper('base64Decode') vnoremap [u :call mine#encoding#wrapper('urlEncode') vnoremap ]u :call mine#encoding#wrapper('urlDecode') vnoremap [U :call mine#encoding#wrapper('urlEncodeAll') vnoremap ]U :call mine#encoding#wrapper('urlDecode') vnoremap [h :call mine#encoding#wrapper('hexEncode') vnoremap ]h :call mine#encoding#wrapper('hexDecode') " Makes the delete key work in insert mode inoremap " Compiles documents " The uppercase versions don't push enter an extra time resulting in seeing " the output of the compile command. Useful for debugging nnoremap cc :w! \| !compiler % nnoremap cC :w! \| !compiler % nnoremap cl :w! \| !compiler % letter nnoremap cL :w! \| !compiler % letter " Opens the compiled documents " If something like html, it doesn't need to be compiled first nnoremap co :!opout % " Makes vim default to "very magic" searching nnoremap / /\v vnoremap / /\v " Makes vim re-select visual selection when using < or > vnoremap < >gv nnoremap [c :cprevious nnoremap ]c :cnext " Run proselint and put it in the quickfix list nnoremap p :call mine#functions#proselint() if has('nvim') if !empty($SUDO_ASKPASS) cnoremap WW w !sudo -A tee % > /dev/null endif else cnoremap WW w !sudo tee % > /dev/null endif