diff options
| author | Hsieh Chin Fan <pham@topo.tw> | 2024-06-20 00:26:26 +0800 |
|---|---|---|
| committer | Hsieh Chin Fan <pham@topo.tw> | 2024-06-20 00:26:26 +0800 |
| commit | d9091ed49cda30b17d41f435c14960f3433fa60b (patch) | |
| tree | c38e7174f0858bdd364c529c92dc1879a2e8dd16 /vim | |
| parent | 898d25eb0402af63af4bd9edfc8db62fcc54bb21 (diff) | |
Update
Diffstat (limited to 'vim')
| -rw-r--r-- | vim/init/basic.vim | 22 | ||||
| -rw-r--r-- | vim/init/keymaps.vim | 21 |
2 files changed, 23 insertions, 20 deletions
diff --git a/vim/init/basic.vim b/vim/init/basic.vim index 09ed985..eb895e2 100644 --- a/vim/init/basic.vim +++ b/vim/init/basic.vim | |||
| @@ -109,19 +109,19 @@ nnoremap gl :call ToggleQuit()<CR> | |||
| 109 | " Simply exit when closing the last buffer | 109 | " Simply exit when closing the last buffer |
| 110 | 110 | ||
| 111 | function! Bye() | 111 | function! Bye() |
| 112 | " Delete current buffer if working on special filetype | 112 | let specialFileTypes = ['help', 'netrw', 'vim-plug', 'nerdtree'] |
| 113 | let specialFileTypes = ['help', 'netrw', 'vim-plug', 'nerdtree'] | 113 | let bufIsSpecial = index(specialFileTypes, &filetype) != -1 |
| 114 | if index(specialFileTypes, &filetype) != -1 | 114 | let bufInMultipleWindow = len(getbufinfo(bufnr())[0].windows) > 1 |
| 115 | :bdelete | 115 | |
| 116 | " Delete current buffer if more than one buffers | 116 | if len(getbufinfo({'buflisted': 1})) == 1 && len(getwininfo()) == 1 |
| 117 | elseif len(getbufinfo(bufnr())[0].windows) == 1 && len(getwininfo()) > 1 | 117 | if g:quitVimWhenPressingCtrlC |
| 118 | :bdelete | 118 | :silent! quit |
| 119 | elseif g:quitVimWhenPressingCtrlC | ||
| 120 | " Otherwise, quit vim | ||
| 121 | :silent! quit | ||
| 122 | else | 119 | else |
| 123 | :echo "Press gl to allow quit with <C-c>" | 120 | :echo "Press gl to allow quit with <C-c>" |
| 124 | endif | 121 | endif |
| 122 | else | ||
| 123 | :bdelete | ||
| 124 | endif | ||
| 125 | endfunction | 125 | endfunction |
| 126 | 126 | ||
| 127 | " Ctrl-C rules!!! | 127 | " Ctrl-C rules!!! |
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index da8ccd0..c57a57c 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | " Only for key mapping | 3 | " Only for key mapping |
| 4 | " | 4 | " |
| 5 | " - COMMON_MAPPING | 5 | " - COMMON_MAPPING |
| 6 | " - LINKS | 6 | " - MANAGE_VIMRC |
| 7 | " - MOVING_WITH_READLINE | 7 | " - MOVING_WITH_READLINE |
| 8 | " - INSERT_SURROUNDING | 8 | " - INSERT_SURROUNDING |
| 9 | " - JUMP_TO_TABS_WITH_ALT | 9 | " - JUMP_TO_TABS_WITH_ALT |
| @@ -51,16 +51,14 @@ nmap <leader>q :cq<cr> | |||
| 51 | " Switch wrap | 51 | " Switch wrap |
| 52 | nmap <leader>W :set wrap!<cr> | 52 | nmap <leader>W :set wrap!<cr> |
| 53 | 53 | ||
| 54 | " Show fold level when it changes | ||
| 55 | nnoremap zm zm:set foldlevel<CR> | ||
| 56 | nnoremap zr zr:set foldlevel<CR> | ||
| 57 | |||
| 54 | " :W sudo saves the file | 58 | " :W sudo saves the file |
| 55 | " (useful for handling the permission-denied error) | 59 | " (useful for handling the permission-denied error) |
| 56 | command! W execute 'w !sudo -S tee %' <bar> edit! | 60 | command! W execute 'w !sudo -S tee %' <bar> edit! |
| 57 | 61 | ||
| 58 | " New tab like browser | ||
| 59 | nmap <C-t>n :tabnew<CR> | ||
| 60 | nmap <C-t>c :tabclose<CR> | ||
| 61 | nmap <C-t>m :tabmove | ||
| 62 | nmap <C-t>o :tabonly | ||
| 63 | |||
| 64 | " Enter to open file | 62 | " Enter to open file |
| 65 | nnoremap <CR> gf | 63 | nnoremap <CR> gf |
| 66 | nnoremap gF :e <cfile><CR> | 64 | nnoremap gF :e <cfile><CR> |
| @@ -126,7 +124,7 @@ vnoremap so :source<CR> | |||
| 126 | 124 | ||
| 127 | 125 | ||
| 128 | "---------------------------------------------------------------------- | 126 | "---------------------------------------------------------------------- |
| 129 | " => Fast editing and reloading of vimrc configs | 127 | " MANAGE_VIMRC |
| 130 | "---------------------------------------------------------------------- | 128 | "---------------------------------------------------------------------- |
| 131 | nnoremap <leader>e :edit $MYVIMRC<CR> | 129 | nnoremap <leader>e :edit $MYVIMRC<CR> |
| 132 | autocmd! bufwritepost $MYVIMRC source $MYVIMRC | 130 | autocmd! bufwritepost $MYVIMRC source $MYVIMRC |
| @@ -205,9 +203,14 @@ inoremap <silent><M-9> <Esc>:tablast<CR> | |||
| 205 | 203 | ||
| 206 | " Useful mappings for managing tabs | 204 | " Useful mappings for managing tabs |
| 207 | map <leader>tn :tabnew<CR> | 205 | map <leader>tn :tabnew<CR> |
| 208 | map <leader>to :tabonly<CR> | ||
| 209 | map <leader>tc :tabclose<CR> | 206 | map <leader>tc :tabclose<CR> |
| 210 | map <leader>tm :tabmove<SPACE> | 207 | map <leader>tm :tabmove<SPACE> |
| 208 | map <leader>to :tabonly<CR> | ||
| 209 | nmap <C-t>n :tabnew<CR> | ||
| 210 | nmap <C-t>c :tabclose<CR> | ||
| 211 | nmap <C-t>m :tabmove | ||
| 212 | nmap <C-t>o :tabonly | ||
| 213 | |||
| 211 | noremap <silent><m-h> :call Tab_MoveLeft()<cr> | 214 | noremap <silent><m-h> :call Tab_MoveLeft()<cr> |
| 212 | noremap <silent><m-l> :call Tab_MoveRight()<cr> | 215 | noremap <silent><m-l> :call Tab_MoveRight()<cr> |
| 213 | 216 | ||