aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-06-20 00:26:26 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-06-20 00:26:26 +0800
commitd9091ed49cda30b17d41f435c14960f3433fa60b (patch)
treec38e7174f0858bdd364c529c92dc1879a2e8dd16 /vim/init
parent898d25eb0402af63af4bd9edfc8db62fcc54bb21 (diff)
Update
Diffstat (limited to 'vim/init')
-rw-r--r--vim/init/basic.vim22
-rw-r--r--vim/init/keymaps.vim21
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
111function! Bye() 111function! 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
125endfunction 125endfunction
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
52nmap <leader>W :set wrap!<cr> 52nmap <leader>W :set wrap!<cr>
53 53
54" Show fold level when it changes
55nnoremap zm zm:set foldlevel<CR>
56nnoremap 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)
56command! W execute 'w !sudo -S tee %' <bar> edit! 60command! W execute 'w !sudo -S tee %' <bar> edit!
57 61
58" New tab like browser
59nmap <C-t>n :tabnew<CR>
60nmap <C-t>c :tabclose<CR>
61nmap <C-t>m :tabmove
62nmap <C-t>o :tabonly
63
64" Enter to open file 62" Enter to open file
65nnoremap <CR> gf 63nnoremap <CR> gf
66nnoremap gF :e <cfile><CR> 64nnoremap 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"----------------------------------------------------------------------
131nnoremap <leader>e :edit $MYVIMRC<CR> 129nnoremap <leader>e :edit $MYVIMRC<CR>
132autocmd! bufwritepost $MYVIMRC source $MYVIMRC 130autocmd! 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
207map <leader>tn :tabnew<CR> 205map <leader>tn :tabnew<CR>
208map <leader>to :tabonly<CR>
209map <leader>tc :tabclose<CR> 206map <leader>tc :tabclose<CR>
210map <leader>tm :tabmove<SPACE> 207map <leader>tm :tabmove<SPACE>
208map <leader>to :tabonly<CR>
209nmap <C-t>n :tabnew<CR>
210nmap <C-t>c :tabclose<CR>
211nmap <C-t>m :tabmove
212nmap <C-t>o :tabonly
213
211noremap <silent><m-h> :call Tab_MoveLeft()<cr> 214noremap <silent><m-h> :call Tab_MoveLeft()<cr>
212noremap <silent><m-l> :call Tab_MoveRight()<cr> 215noremap <silent><m-l> :call Tab_MoveRight()<cr>
213 216