diff options
Diffstat (limited to 'vim/init/basic.vim')
-rw-r--r-- | vim/init/basic.vim | 65 |
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 |
14 | augroup END | 14 | augroup END |
15 | |||
15 | " }}} | 16 | " }}} |
16 | " GERERNAL ----------------{{{ | 17 | " GERERNAL ----------------{{{ |
18 | |||
17 | let mapleader = "," " Always use comma as leader key | 19 | let mapleader = "," " Always use comma as leader key |
18 | set nocompatible " Disable vi compatible, today is 20XX | 20 | set nocompatible " Disable vi compatible, today is 20XX |
19 | set path=.,** " Allow :find with completion | 21 | set 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 |
33 | set autoread | 35 | set autoread |
34 | autocmd FocusGained,BufEnter .* checktime | 36 | autocmd 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 |
65 | set errorformat+=[%f:%l]\ ->\ %m,[%f:%l]:%m | 68 | set errorformat+=[%f:%l]\ ->\ %m,[%f:%l]:%m |
66 | 69 | ||
67 | " 顯示分隔符號 | ||
68 | set listchars=tab:\|\ ,trail:.,extends:>,precedes:< | ||
69 | |||
70 | " }}} | 70 | " }}} |
71 | " EDIT ----------------{{{ | 71 | " EDIT ----------------{{{ |
72 | 72 | ||
73 | set backspace=eol,start,indent " Set Backspace behaviors | 73 | set backspace=eol,start,indent " Set Backspace behaviors |
74 | set autoindent " If current line has indent, automatically set indent for next line | 74 | set autoindent smartindent |
75 | set shiftwidth=2 | ||
75 | set cindent | 76 | set cindent |
76 | set ttimeout | 77 | set ttimeout |
77 | set ttimeoutlen=50 | 78 | set ttimeoutlen=50 |
@@ -80,14 +81,14 @@ set ttimeoutlen=50 | |||
80 | 81 | ||
81 | imap <C-c> <Esc>l | 82 | imap <C-c> <Esc>l |
82 | 83 | ||
83 | " TABSIZE ----------------{{{ | 84 | " TAB ----------------{{{ |
84 | 85 | ||
85 | set expandtab | 86 | set expandtab |
86 | set shiftwidth=2 | 87 | set softtabstop=-1 |
87 | set autoindent | 88 | |
88 | set tabstop=4 | 89 | " 顯示分隔符號 |
89 | set softtabstop=0 | 90 | set list |
90 | set smartindent | 91 | set 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 ----------------{{{ |
102 | set ignorecase " Search case without case sensation | 103 | |
104 | set ignorecase " Search case without case sensation | ||
103 | set smartcase | 105 | set smartcase |
104 | set hlsearch " Hilight all matched texts | 106 | set hlsearch " Hilight all matched texts |
105 | set incsearch " Show matched strings when typing | 107 | set incsearch " Show matched strings when typing |
108 | |||
106 | " }}} | 109 | " }}} |
107 | " BUFFERS ----------------{{{ | 110 | " BUFFERS ----------------{{{ |
108 | 111 | ||
109 | " Use <C-c> to quit the last buffer ----------------{{{ | ||
110 | let g:quitVimWhenPressingCtrlC = 1 | ||
111 | function! ToggleQuit() | ||
112 | let g:quitVimWhenPressingCtrlC = g:quitVimWhenPressingCtrlC ? 0 : 1 | ||
113 | let message = g:quitVimWhenPressingCtrlC ? "Unlock" : "Lock" | ||
114 | echo message | ||
115 | endfunction | ||
116 | |||
117 | nnoremap <leader><leader>gl :call ToggleQuit()<CR> | ||
118 | |||
119 | function! 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 | ||
129 | endfunction | ||
130 | |||
131 | " Ctrl-C rules!!! | ||
132 | nnoremap <silent> <C-c> :call Bye()<CR> | ||
133 | |||
134 | " }}} | ||
135 | " Go to last cursor position ----------------{{{ | 112 | " Go to last cursor position ----------------{{{ |
136 | augroup vimStartup | 113 | augroup 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 |
146 | augroup END | 123 | augroup END |
147 | 124 | ||
@@ -158,10 +135,12 @@ if has('multi_byte') | |||
158 | endif | 135 | endif |
159 | 136 | ||
160 | " }}} | 137 | " }}} |
161 | " FOLDING ----------------{{{ | 138 | " FOLD ----------------{{{ |
139 | |||
162 | set foldenable " Allow fold | 140 | set foldenable " Allow fold |
163 | set foldmethod=indent " Fold contents by indent | 141 | set foldmethod=indent " Fold contents by indent |
164 | set foldlevel=2 | 142 | set 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 |
178 | set writebackup | 157 | set writebackup |
158 | |||
179 | " }}} | 159 | " }}} |
180 | " HIGHLIGHT ----------------{{{ | 160 | " HIGHLIGHT ----------------{{{ |
161 | |||
181 | syntax enable | 162 | syntax enable |
182 | set conceallevel=1 | 163 | set 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 |
188 | endfunction | 169 | endfunction |
170 | nnoremap <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 | |||
203 | nnoremap <silent> <leader>gh :call matchadd('MultiLineHighlight', '\%'.line('.').'l')<CR> | 185 | nnoremap <silent> <leader>gh :call matchadd('MultiLineHighlight', '\%'.line('.').'l')<CR> |
204 | " clear all the highlighted lines | 186 | " clear all the highlighted lines |
205 | nnoremap <silent> <leader>gH :call clearmatches()<CR> | 187 | nnoremap <silent> <leader>gH :call clearmatches()<CR> |
188 | |||
206 | " }}} | 189 | " }}} |
207 | " MISC ----------------{{{ | 190 | " MISC ----------------{{{ |
208 | 191 | ||