diff options
| author | jdhao <jdhao@hotmail.com> | 2020-09-26 09:15:40 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2020-09-26 09:15:40 +0800 |
| commit | b65c7c6d702ba0371e917066b55a58cf14f2d1bb (patch) | |
| tree | 801a9cab3e33120ee8a7781c1ccb28522b59b269 /autocommands.vim | |
| parent | c248ab02d40249479ca5c0f75ae580e5f2074239 (diff) | |
change vim script style from 4-space indent to 2-space
Diffstat (limited to 'autocommands.vim')
| -rw-r--r-- | autocommands.vim | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/autocommands.vim b/autocommands.vim index e0f2861..3791a07 100644 --- a/autocommands.vim +++ b/autocommands.vim @@ -1,41 +1,38 @@ "{ Auto commands " Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292. augroup dynamic_smartcase - autocmd! - autocmd CmdLineEnter : set nosmartcase - autocmd CmdLineLeave : set smartcase + autocmd! + autocmd CmdLineEnter : set nosmartcase + autocmd CmdLineLeave : set smartcase augroup END augroup term_settings - autocmd! - " Do not use number and relative number for terminal inside nvim - autocmd TermOpen * setlocal norelativenumber nonumber - " Go to insert mode by default to start typing command - autocmd TermOpen * startinsert + autocmd! + " Do not use number and relative number for terminal inside nvim + autocmd TermOpen * setlocal norelativenumber nonumber + " Go to insert mode by default to start typing command + autocmd TermOpen * startinsert augroup END " More accurate syntax highlighting? (see `:h syn-sync`) augroup accurate_syn_highlight - autocmd! - autocmd BufEnter * :syntax sync fromstart + autocmd! + autocmd BufEnter * :syntax sync fromstart augroup END " Return to last edit position when opening a file augroup resume_edit_position - autocmd! - autocmd BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' - \ | execute "normal! g`\"zvzz" - \ | endif + autocmd! + autocmd BufReadPost * + \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' | execute "normal! g`\"zvzz" | endif augroup END " Display a message when the current file is not in utf-8 format. " Note that we need to use `unsilent` command here because of this issue: " https://github.com/vim/vim/issues/4379 augroup non_utf8_file_warn - autocmd! - autocmd BufRead * if &fileencoding != 'utf-8' - \ | unsilent echomsg 'File not in UTF-8 format!' | endif + autocmd! + autocmd BufRead * if &fileencoding != 'utf-8' | unsilent echomsg 'File not in UTF-8 format!' | endif augroup END " Automatically reload the file if it is changed outside of Nvim, see @@ -44,11 +41,11 @@ augroup END " line before executing this command. See also " https://vi.stackexchange.com/a/20397/15292. augroup auto_read - autocmd! - autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * - \ if mode() == 'n' && getcmdwintype() == '' | checktime | endif - autocmd FileChangedShellPost * echohl WarningMsg - \ | echo "File changed on disk. Buffer reloaded!" | echohl None + autocmd! + autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * + \ if mode() == 'n' && getcmdwintype() == '' | checktime | endif + autocmd FileChangedShellPost * echohl WarningMsg + \ | echo "File changed on disk. Buffer reloaded!" | echohl None augroup END augroup numbertoggle @@ -59,12 +56,12 @@ augroup END " highlight yanked region, see `:h lua-highlight` augroup custom_highlight - autocmd! - autocmd ColorScheme * highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71 + autocmd! + autocmd ColorScheme * highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71 augroup END augroup highlight_yank - autocmd! - au TextYankPost * silent! lua vim.highlight.on_yank{higroup="YankColor", timeout=700} + autocmd! + au TextYankPost * silent! lua vim.highlight.on_yank{higroup="YankColor", timeout=700} augroup END "} |
