-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautocommands.vim
38 lines (28 loc) · 1.46 KB
/
autocommands.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
" =============================================================================
" ==/ ------- -------- \==
" Autocommands
" ==\ ------- -------- /==
" =============================================================================
"
" ==| ------- 1. Global -------- |==
"
" Strip formatting from newlines
autocmd BufNewFile,BufEnter * set formatoptions-=o
" Strip trailing whitespace from files
autocmd BufWritePre * silent! :StripTrailingWhiteSpace
"
" ==| ------- 2. UI -------- |==
"
" Resize splits when the window is resized
autocmd VimResized * :wincmd =
"
" ==| ------- 3. Plugins -------- |==
"
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
" If another buffer tries to replace NERDTree, put it in the other window, and
" bring back NERDTree.
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" Set JSX/TSX filetypes as typescriptreact to use 'vim-jsx-typescript'
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescriptreact