Skip to content

Instantly share code, notes, and snippets.

@miles-d
Created December 13, 2020 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miles-d/7c4b4ed20452195dd00f541f835d6681 to your computer and use it in GitHub Desktop.
Save miles-d/7c4b4ed20452195dd00f541f835d6681 to your computer and use it in GitHub Desktop.
All the autocommands in my vimrc.
augroup USER
autocmd!
autocmd BufReadPost fugitive://* set bufhidden=delete
autocmd FileType vimwiki setlocal textwidth=0
autocmd FileType vimwiki setlocal foldmethod=manual
autocmd FileType vimwiki,markdown setlocal keywordprg=dict
autocmd FileType coffee,javascript,python,vimwiki,css,ruby setlocal shiftwidth=2 tabstop=2
autocmd FileType python,php,javascript,java,ruby,c,typescript iabbrev <buffer> ret return
autocmd FileType php,java iabbrev <buffer> pv private
autocmd FileType php,java iabbrev <buffer> pub public
autocmd FileType php,java iabbrev <buffer> pum public function
autocmd FileType php,java iabbrev <buffer> pvm private function
autocmd FileType php,java iabbrev <buffer> prot protected
autocmd FileType php,java iabbrev <buffer> fun function
autocmd FileType php iabbrev <buffer> stat static function
autocmd FileType java iabbrev <buffer> stat static
autocmd FileType php nmap <buffer> <space>/ /function<space>
autocmd FileType python nnoremap <buffer> <localleader>; A:<Esc>
autocmd FileType python nnoremap ,cc "zyiwoprint('<c-r>z', <c-r>z)<esc>
autocmd FileType python nmap <buffer> <space>f :vimgrep 'def ' %<CR>:cw<CR>
autocmd FileType python imap <buffer> gj self
autocmd FileType python setlocal keywordprg=pydoc3
autocmd FileType python imap <buffer> sup<c-i> def setUp(self):<cr>
autocmd FileType python imap <buffer> h<c-i> print()<esc>i
autocmd FileType python imap <buffer> ase<c-i> self.assertEqual(X)<esc>FXs
autocmd FileType python imap <buffer> ast<c-i> self.assertTrue(X)<esc>FXs
autocmd FileType python imap <buffer> asf<c-i> self.assertFalse(X)<esc>FXs
autocmd FileType python imap <buffer> x<c-i> @unittest.skip('X')<esc>FXs
autocmd FileType python inoremap <buffer> <c-r>g <esc>:call SetterAssignmentPython()<cr>
autocmd FileType sh setlocal sw=4 ts=4
autocmd FileType php setlocal sw=4 ts=4
autocmd FileType php setlocal keywordprg=pman
autocmd FileType php setlocal commentstring=//\ %s
autocmd FileType php setlocal iskeyword+=$
autocmd FileType java nmap <leader>jh :JavaImport<cr>
autocmd FileType java setlocal tags+=~/.javatags
autocmd FileType java inoremap h<c-i> System.out.println();<LEFT><LEFT>
autocmd FileType vue setlocal commentstring=//\ %s
autocmd FileType vue,typescript,typescript.tsx set hidden
autocmd FileType typescript,typescriptreact setlocal completeopt=menuone
autocmd FileType javascript,typescript nnoremap <buffer> <leader>jb :call JsBind()<cr>
autocmd FileType javascript,typescript nnoremap <buffer> <leader>jib :call JsBindInConstructor()<cr>
autocmd FileType javascript,typescript,typescriptreact imap <buffer> h<c-i> console.log(X)<esc>FXs
autocmd FileType typescript,vue,typescript.tsx,typescriptreact imap <buffer> h<c-i> console.log(X); // eslint-disable-line<esc>FXs
autocmd FileType javascript,typescript,typescriptreact imap <buffer> fl<c-i> console.log('<c-r>=expand("%:t")<cr>')<esc>
autocmd FileType javascript nnoremap ,cc "zyiwoconsole.log('<c-r>z', <c-r>z)<esc>
autocmd FileType typescript,vue nnoremap ,cc "zyiwoconsole.log('<c-r>z', <c-r>z); // eslint-disable-line<esc>
autocmd FileType typescript setlocal errorformat=%.%#FAIL\ %m
autocmd BufWritePost ~/proj/vimrc/colors/*.vim source %
autocmd BufWritePost ~/.vimrc source % | redraw | echo "Reloaded vimrc!"
autocmd FileType vim setlocal sw=2 ts=2
autocmd FileType clojure nmap <localleader>m :Eval<cr>
autocmd FileType clojure setlocal sw=2 ts=2
autocmd FileType css imap <buffer> ,, !important
autocmd FileType css nmap <buffer> ,, i !important<ESC>
autocmd FileType gitcommit nnoremap <buffer> ,, :read !git symbolic-ref HEAD \| xargs basename \| sed -E 's/[^0-9]+$//'<cr>kddA:
autocmd BufNewFile,BufRead *.html setlocal filetype=htmldjango
autocmd BufNewFile,BufRead *.md setlocal ft=markdown
autocmd FileType remind setlocal commentstring=#\ %s
autocmd FileType crontab setlocal commentstring=#\ %s
autocmd FileType yaml setlocal foldmethod=syntax
autocmd FileType typescriptreact setlocal commentstring=//%s
autocmd BufReadPost,FileReadPost *.pdf file <afile>:r | edit <afile>:r | set buftype=nofile | set bufhidden=delete | set readonly | %!pdftotext <afile> -
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment