aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init/basic.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/init/basic.vim')
-rw-r--r--vim/init/basic.vim65
1 files changed, 24 insertions, 41 deletions
diff --git a/vim/init/basic.vim b/vim/init/basic.vim
index a54bf59..c066f07 100644
--- a/vim/init/basic.vim
+++ b/vim/init/basic.vim
@@ -12,8 +12,10 @@ augroup filetype_vim
12 execute "autocmd FileType vim :inoreabbrev <buffer> --- ----------------{".."{{" 12 execute "autocmd FileType vim :inoreabbrev <buffer> --- ----------------{".."{{"
13 autocmd FileType vim setlocal foldmethod=marker foldlevel=0 13 autocmd FileType vim setlocal foldmethod=marker foldlevel=0
14augroup END 14augroup END
15
15" }}} 16" }}}
16" GERERNAL ----------------{{{ 17" GERERNAL ----------------{{{
18
17let mapleader = "," " Always use comma as leader key 19let mapleader = "," " Always use comma as leader key
18set nocompatible " Disable vi compatible, today is 20XX 20set nocompatible " Disable vi compatible, today is 20XX
19set path=.,** " Allow :find with completion 21set path=.,** " Allow :find with completion
@@ -32,6 +34,7 @@ filetype plugin indent on
32" Unnamed buffer like CmdWindows should prevent this 34" Unnamed buffer like CmdWindows should prevent this
33set autoread 35set autoread
34autocmd FocusGained,BufEnter .* checktime 36autocmd FocusGained,BufEnter .* checktime
37
35" }}} 38" }}}
36" VISUAL ----------------{{{ 39" VISUAL ----------------{{{
37 40
@@ -64,14 +67,12 @@ set wildmenu wildoptions=pum,fuzzy
64" Format of error message 67" Format of error message
65set errorformat+=[%f:%l]\ ->\ %m,[%f:%l]:%m 68set errorformat+=[%f:%l]\ ->\ %m,[%f:%l]:%m
66 69
67" 顯示分隔符號
68set listchars=tab:\|\ ,trail:.,extends:>,precedes:<
69
70" }}} 70" }}}
71" EDIT ----------------{{{ 71" EDIT ----------------{{{
72 72
73set backspace=eol,start,indent " Set Backspace behaviors 73set backspace=eol,start,indent " Set Backspace behaviors
74set autoindent " If current line has indent, automatically set indent for next line 74set autoindent smartindent
75set shiftwidth=2
75set cindent 76set cindent
76set ttimeout 77set ttimeout
77set ttimeoutlen=50 78set ttimeoutlen=50
@@ -80,14 +81,14 @@ set ttimeoutlen=50
80 81
81imap <C-c> <Esc>l 82imap <C-c> <Esc>l
82 83
83" TABSIZE ----------------{{{ 84" TAB ----------------{{{
84 85
85set expandtab 86set expandtab
86set shiftwidth=2 87set softtabstop=-1
87set autoindent 88
88set tabstop=4 89" 顯示分隔符號
89set softtabstop=0 90set list
90set smartindent 91set listchars=tab:▷▷,extends:>,precedes:<
91 92
92" }}} 93" }}}
93 94
@@ -99,39 +100,15 @@ set suffixesadd=.md " Enable reference markdown file without extension
99 100
100" }}} 101" }}}
101" SEARCH ----------------{{{ 102" SEARCH ----------------{{{
102set ignorecase " Search case without case sensation 103
104set ignorecase " Search case without case sensation
103set smartcase 105set smartcase
104set hlsearch " Hilight all matched texts 106set hlsearch " Hilight all matched texts
105set incsearch " Show matched strings when typing 107set incsearch " Show matched strings when typing
108
106" }}} 109" }}}
107" BUFFERS ----------------{{{ 110" BUFFERS ----------------{{{
108 111
109" Use <C-c> to quit the last buffer ----------------{{{
110let g:quitVimWhenPressingCtrlC = 1
111function! ToggleQuit()
112 let g:quitVimWhenPressingCtrlC = g:quitVimWhenPressingCtrlC ? 0 : 1
113 let message = g:quitVimWhenPressingCtrlC ? "Unlock" : "Lock"
114 echo message
115endfunction
116
117nnoremap <leader><leader>gl :call ToggleQuit()<CR>
118
119function! Bye()
120 if len(getbufinfo({'buflisted': 1})) == 1 && len(getwininfo()) == 1
121 if g:quitVimWhenPressingCtrlC
122 :silent! quit
123 else
124 :echo "Press <leader><leader>gl to allow quit with <C-c>"
125 endif
126 else
127 :bdelete
128 endif
129endfunction
130
131" Ctrl-C rules!!!
132nnoremap <silent> <C-c> :call Bye()<CR>
133
134" }}}
135" Go to last cursor position ----------------{{{ 112" Go to last cursor position ----------------{{{
136augroup vimStartup 113augroup vimStartup
137 au! 114 au!
@@ -141,7 +118,7 @@ augroup vimStartup
141 " (it's likely a different one than last time). 118 " (it's likely a different one than last time).
142 autocmd BufReadPost * 119 autocmd BufReadPost *
143 \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit' 120 \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
144 \ | exe "normal! g`\"" 121 \ | exe "normal! g`\"zv"
145 \ | endif 122 \ | endif
146augroup END 123augroup END
147 124
@@ -158,10 +135,12 @@ if has('multi_byte')
158endif 135endif
159 136
160" }}} 137" }}}
161" FOLDING ----------------{{{ 138" FOLD ----------------{{{
139
162set foldenable " Allow fold 140set foldenable " Allow fold
163set foldmethod=indent " Fold contents by indent 141set foldmethod=indent " Fold contents by indent
164set foldlevel=2 142set foldlevel=2
143
165" }}} 144" }}}
166" BACKUP ----------------{{{ 145" BACKUP ----------------{{{
167 146
@@ -176,8 +155,10 @@ set backupdir=~/.vim/tmp
176 155
177" backup when write file 156" backup when write file
178set writebackup 157set writebackup
158
179" }}} 159" }}}
180" HIGHLIGHT ----------------{{{ 160" HIGHLIGHT ----------------{{{
161
181syntax enable 162syntax enable
182set conceallevel=1 163set conceallevel=1
183 164
@@ -186,6 +167,7 @@ function! GetHighlightGroupName()
186 let l:groupName = synIDattr(l:syntaxID, 'name') 167 let l:groupName = synIDattr(l:syntaxID, 'name')
187 echo "Highlight Group Name: " . l:groupName 168 echo "Highlight Group Name: " . l:groupName
188endfunction 169endfunction
170nnoremap <leader>H :call GetHighlightGroupName()<CR>
189 171
190" Defualt highlight for matched parenthesis is so weird in many colorscheme 172" Defualt highlight for matched parenthesis is so weird in many colorscheme
191" Why the background color is lighter than my caret !? 173" Why the background color is lighter than my caret !?
@@ -203,6 +185,7 @@ highlight MultiLineHighlight ctermbg=LightYellow guibg=LightYellow ctermfg=Black
203nnoremap <silent> <leader>gh :call matchadd('MultiLineHighlight', '\%'.line('.').'l')<CR> 185nnoremap <silent> <leader>gh :call matchadd('MultiLineHighlight', '\%'.line('.').'l')<CR>
204" clear all the highlighted lines 186" clear all the highlighted lines
205nnoremap <silent> <leader>gH :call clearmatches()<CR> 187nnoremap <silent> <leader>gH :call clearmatches()<CR>
188
206" }}} 189" }}}
207" MISC ----------------{{{ 190" MISC ----------------{{{
208 191