" Save file as root when I forgot to use sudoedit cnoremap w!! execute 'write !sudo tee % >/dev/null' edit! " Write file & source vimrc (really only makes sense from within vimrc to quickly test changes) command! WS write source $MYVIMRC command! FormatJSON %!python -m json.tool command! DiffSwap :diffsp % " Diff for swap - replaced by 'chrisbra/Recover.vim' " shebang shortcut - https://www.reddit.com/r/vim/comments/4z7z7s/add_shebang_lines_to_your_vim_files_automatically/d6v7op8 and https://stackoverflow.com/a/52135425 inoreabbrev #!! "#!/usr/bin/env" . (empty(&filetype) ? '' : ' '.&filetype) autocmd BufNewFile *.sh execute 'silent! 1s/.*/#!\/bin\/sh\r\r'| :startinsert "autocmd BufNewFile * if !empty(&filetype) | execute 'silent! 1s/.*/#!\/usr\/bin\/' . &filetype . '\r\r'| :startinsert | endif " Sane yanking map Y y$ " Disable Ex mode - https://vi.stackexchange.com/q/457 nnoremap Q let mapleader=" " " Alias write and quit to leader nnoremap q :wq nnoremap w :w " Easy split navigation nnoremap nnoremap nnoremap nnoremap " Shortcut split opening nnoremap h :split nnoremap v :vsplit " Alias replace all to S nnoremap S :%s//gI " Jump around without shift nnoremap gl $ nnoremap gh 0 nnoremap gk H nnoremap gj L nnoremap gt gg nnoremap gb G " Enable and disable auto comment map c :setlocal formatoptions-=cro map C :setlocal formatoptions=cro map i :setlocal autoindent! map s :setlocal spell! " }}}