regroup autocmds and add default check
This commit is contained in:
parent
5fd4f8d7cb
commit
0eee969d73
49
vim/vimrc
49
vim/vimrc
@ -7,6 +7,12 @@
|
|||||||
"general settings
|
"general settings
|
||||||
"------------------------------------------------------------------------------
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"load defaults if available
|
||||||
|
if filereadable(expand('$VIMRUNTIME/defaults.vim'))
|
||||||
|
unlet! g:skip_defaults_vim
|
||||||
|
source $VIMRUNTIME/defaults.vim
|
||||||
|
endif
|
||||||
|
|
||||||
"encoding/format
|
"encoding/format
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
set fileformats=unix,dos,mac
|
set fileformats=unix,dos,mac
|
||||||
@ -319,60 +325,31 @@ if has("autocmd")
|
|||||||
"------------
|
"------------
|
||||||
"## global ##
|
"## global ##
|
||||||
"------------
|
"------------
|
||||||
|
augroup general
|
||||||
|
autocmd!
|
||||||
"set plugin settings on VimEnter
|
"set plugin settings on VimEnter
|
||||||
augroup set_plugin_settings
|
|
||||||
autocmd!
|
|
||||||
autocmd VimEnter * call SetPluginSettings()
|
autocmd VimEnter * call SetPluginSettings()
|
||||||
augroup END
|
|
||||||
|
|
||||||
"keep equal proportions when windows resized
|
"keep equal proportions when windows resized
|
||||||
augroup auto_resize_windows
|
|
||||||
autocmd!
|
|
||||||
autocmd VimResized * wincmd =
|
autocmd VimResized * wincmd =
|
||||||
augroup END
|
|
||||||
|
|
||||||
"save cursor position in a file
|
"save cursor position in a file
|
||||||
au BufReadPost * if line("'\"") > 1 && line("'\"")
|
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
|
||||||
\ <= line("$") | exe "normal! g'\"" | endif
|
\ <= line("$") | exe "normal! g'\"" | endif
|
||||||
|
augroup END
|
||||||
|
|
||||||
"--------------------------------
|
"--------------------------------
|
||||||
"## language/filetype specific ##
|
"## language/filetype specific ##
|
||||||
"--------------------------------
|
"--------------------------------
|
||||||
|
augroup languages
|
||||||
|
autocmd!
|
||||||
"shell
|
"shell
|
||||||
augroup filetype_shell
|
|
||||||
autocmd!
|
|
||||||
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
||||||
augroup END
|
|
||||||
|
|
||||||
"python
|
"python
|
||||||
augroup filetype_python
|
|
||||||
autocmd!
|
|
||||||
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
||||||
augroup END
|
|
||||||
|
|
||||||
"go
|
"go
|
||||||
augroup filetype_go
|
autocmd FileType go set expandtab! "go uses real tabs
|
||||||
autocmd!
|
|
||||||
set expandtab! "go uses real tabs
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"html
|
"html
|
||||||
augroup filetype_html
|
|
||||||
autocmd!
|
|
||||||
autocmd FileType html :syntax sync fromstart
|
autocmd FileType html :syntax sync fromstart
|
||||||
augroup END
|
|
||||||
|
|
||||||
"markdown
|
|
||||||
augroup filetype_md
|
|
||||||
autocmd!
|
|
||||||
autocmd FileType markdown setlocal sw=4 ts=4 sts=4 expandtab
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
"filestypes where tabs should = 2 spaces
|
"filestypes where tabs should = 2 spaces
|
||||||
augroup half_tab
|
|
||||||
autocmd!
|
|
||||||
autocmd FileType html,javascript,css,json,yaml,sh
|
autocmd FileType html,javascript,css,json,yaml,sh
|
||||||
\ setlocal ts=2 sts=2 sw=2 expandtab
|
\ setlocal ts=2 sts=2 sw=2 expandtab
|
||||||
augroup END
|
augroup END
|
||||||
|
|||||||
@ -1,7 +1,13 @@
|
|||||||
"
|
"
|
||||||
" minimal vimrc with no plugins
|
" minimal vimrc with no (extra) plugins
|
||||||
"
|
"
|
||||||
|
|
||||||
|
"load defaults if available
|
||||||
|
if filereadable(expand('$VIMRUNTIME/defaults.vim'))
|
||||||
|
unlet! g:skip_defaults_vim
|
||||||
|
source $VIMRUNTIME/defaults.vim
|
||||||
|
endif
|
||||||
|
|
||||||
" ui
|
" ui
|
||||||
set number
|
set number
|
||||||
set ruler
|
set ruler
|
||||||
@ -35,18 +41,28 @@ set esckeys
|
|||||||
set ttimeoutlen=20
|
set ttimeoutlen=20
|
||||||
set timeoutlen=1000
|
set timeoutlen=1000
|
||||||
|
|
||||||
" filetype autocmds
|
" autocmds
|
||||||
|
|
||||||
"markdown
|
augroup general
|
||||||
augroup filetype_md
|
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType markdown setlocal sw=4 ts=4 sts=4 expandtab
|
"keep equal proportions when windows resized
|
||||||
|
autocmd VimResized * wincmd =
|
||||||
|
"save cursor position in a file
|
||||||
|
autocmd BufReadPost * if line("'\"") > 1 && line("'\"")
|
||||||
|
\ <= line("$") | exe "normal! g'\"" | endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
"filestypes where tabs should = 2 spaces
|
augroup languages
|
||||||
augroup half_tab
|
|
||||||
autocmd!
|
autocmd!
|
||||||
|
"shell
|
||||||
|
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
||||||
|
"python
|
||||||
|
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
||||||
|
"go
|
||||||
|
autocmd FileType go set expandtab! "go uses real tabs
|
||||||
|
"html
|
||||||
|
autocmd FileType html :syntax sync fromstart
|
||||||
|
"filestypes where tabs should = 2 spaces
|
||||||
autocmd FileType html,javascript,css,json,yaml,sh
|
autocmd FileType html,javascript,css,json,yaml,sh
|
||||||
\ setlocal ts=2 sts=2 sw=2 expandtab
|
\ setlocal ts=2 sts=2 sw=2 expandtab
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user