-
Notifications
You must be signed in to change notification settings - Fork 127
/
autocmds.vim
57 lines (46 loc) · 2.12 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
" ----------------------------------------
" 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
" No more complaining about untitled documents
autocmd FocusLost silent! :wa
" 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 my most used programming langauges
autocmd BufWritePre *.py,*.coffee,*.rb,*.erb,*.md,*.scss,*.vim,Cakefile,
\*.hbs
\ 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>
" Fix accidental indentation in html files
" from http://morearty.com/blog/2013/01/22/fixing-vims-indenting-of-html-files.html
autocmd FileType html setlocal indentkeys-=*<Return>
" 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()
" Resize splits when the window is resized
" from https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc
au VimResized * :wincmd =
" via https://jdhao.github.io/2020/05/22/highlight_yank_region_nvim
au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=400}
" Highlight .mdx files as markdown
autocmd BufRead,BufNewFile *.mdx set filetype=markdown
" Set conceallevel to 2 for json files
autocmd FileType json setlocal conceallevel=2
augroup END
endif