forked from mutewinter/dot_vim
-
Notifications
You must be signed in to change notification settings - Fork 2
/
autocmds.vim
70 lines (56 loc) · 2.53 KB
/
autocmds.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
" ----------------------------------------
" Auto Commands
" ----------------------------------------
if has("autocmd")
augroup MyAutoCommands
" Clear the auto command group so we don't define it multiple times
" Idea from http://learnvimscriptthehardway.stevelosh.com/chapters/14.html
autocmd!
" No formatting on o key newlines
autocmd BufNewFile,BufEnter * set formatoptions-=o
" When editing a file, always jump to the last cursor position.
" This must be after the uncompress commands.
autocmd BufReadPost *
\ if line("'\"") > 1 && line ("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Fix trailing whitespace in all files
" autocmd BufWritePre * silent! :StripTrailingWhiteSpace
" Help mode bindings
" <enter> to follow tag, <bs> to go back, and q to quit.
" From http://ctoomey.com/posts/an-incremental-approach-to-vim/
autocmd filetype help nnoremap <buffer><cr> <c-]>
autocmd filetype help nnoremap <buffer><bs> <c-T>
autocmd filetype help nnoremap <buffer>q :q<CR>
" Leave the return key alone when in command line windows, since it's used
" to run commands there.
autocmd! CmdwinEnter * :unmap <cr>
autocmd! CmdwinLeave * :call MapCR()
" Show normal line numbers when focused and when in insert mode
" autocmd InsertEnter * :set norelativenumber
" autocmd FocusLost * :set norelativenumber
" Show relative numbers when not focused or in normal mode
" autocmd InsertLeave * :set relativenumber
" autocmd FocusGained * if &modifiable | :set relativenumber | endif
" Automatically close terminal buffers that have ended
" (no more [Process exited 0] !!)
autocmd TermClose * call feedkeys('<cr>')
" Automatically enter insert mode when switching to a terminal
autocmd BufEnter term://* :start
" Hide unneeded line highlight in terminals
autocmd TermOpen * :set nocursorline
" Close FZF if it loses focus
autocmd BufLeave *#FZF :bd!
" autocmd FileType javascript.jsx,javascript set formatprg=prettier-standard
" autocmd BufWritePre *.js :normal gggqG
" autocmd BufWritePre * Neoformat
" Fix syntax highlighting in Vue files
autocmd FileType vue syntax sync fromstart
" Fix highlighting in markdown files
" autocmd FileType markdown colorscheme zenfly
" autocmd FileType mdx colorscheme zenfly
autocmd BufRead,BufNewFile *.md setlocal spell
autocmd BufRead,BufNewFile *.mdx setlocal spell
autocmd FileType gitcommit setlocal spell
augroup END
endif