-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zvimrc
341 lines (313 loc) · 9.87 KB
/
.zvimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
let mapleader=";"
filetype on
filetype plugin on
set backspace=2
"focus on edition{{{
set gcr=a:block-blinkon0
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
set guioptions-=m
set guioptions-=T
set laststatus=2
set ruler
set number
set cursorline
set cursorcolumn
set hlsearch
set incsearch
set ignorecase
set nocompatible
set wildmenu
"}}} focus end
"basic operation{{{
vnoremap <Leader>y "+y
vnoremap <Leader>e <Esc>
inoremap <Leader>e <Esc>
inoremap <Leader>w <Esc>:w<CR>
nmap <Leader>p "+p
nmap <Leader>q :q<CR>
nmap <Leader>w :w<CR>
nmap <Leader>WQ :wa<CR>:q<CR>
nmap <Leader>Q :qa!<CR>
" control nerdtree to jump between child windows
"nnoremap nw <C-W><C-W>
nnoremap <Leader>f <C-W>l
nnoremap <Leader>a <C-W>h
nnoremap <Leader>s <C-W>k
nnoremap <Leader>d <C-W>j
nmap <Leader>M %
nnoremap <Leader>h 0
nnoremap <Leader>l $
" paging
nnoremap <Leader>j <C-f>
nnoremap <Leader>k <C-b>
" add "" '' () {} [] <> at selected word in normal mode
nnoremap <Leader>" viw<esc>a"<esc>hbi"<esc>lel
nnoremap <Leader>' viw<esc>a'<esc>hbi'<esc>lel
nnoremap <Leader>` viw<esc>a><esc>hbi<<esc>lel
nnoremap <Leader>( viw<esc>a)<esc>hbi(<esc>lel
nnoremap <Leader>{ viw<esc>a}<esc>hbi{<esc>lel
nnoremap <Leader>[ viw<esc>a]<esc>hbi[<esc>lel
nnoremap <Leader>< viw<esc>a><esc>hbi<<esc>lel
" add "" '' () {} [] <> at selected word in insert mode
inoremap <Leader>" <esc>viw<esc>a"<esc>hbi"<esc>lela
inoremap <Leader>' <esc>viw<esc>a'<esc>hbi'<esc>lela
inoremap <Leader>` <esc>viw<esc>a><esc>hbi<<esc>lela
inoremap <Leader>( <esc>viw<esc>a)<esc>hbi(<esc>lela
inoremap <Leader>{ <esc>viw<esc>a}<esc>hbi{<esc>lela
inoremap <Leader>[ <esc>viw<esc>a]<esc>hbi[<esc>lela
inoremap <Leader>< <esc>viw<esc>a><esc>hbi<<esc>lela
" add "" '' () {} [] <> at selected word without <Leader>
inoremap " ""<esc>i
inoremap ' ''<esc>i
inoremap ( ()<esc>i
inoremap { {}<esc>i
inoremap [ []<esc>i
inoremap < <><esc>i
" auto complete () {} []
inoremap {<cr> {<cr>}<esc>k$a<cr>
inoremap (<cr> (<cr>)<esc>k$a<cr>
inoremap [<cr> [<cr>]<esc>k$a<cr>
" resize window
nnoremap < :vertical resize +3<cr>
nnoremap > :vertical resize -3<cr>
nnoremap + :resize +3<cr>
nnoremap _ :resize -3<cr>
" auto reload directory
"set autoread
" enable mouse
set mouse=a
" jump among files
nnoremap <Leader>P :e#<CR>
" delete in insert mode
inoremap <Leader>dd <esc>ddi
" paste in insert mode
inoremap <Leader>pp <esc>pi
"}}}basic end
"auto command{{{
au BufNewFile,BufRead *.wxml set filetype=html
augroup FreshVimrc
autocmd!
autocmd BufWritePost ~/.zvimrc source ~/.zvimrc
augroup END
" In this part we open the indicated file's directory in nerdtree window
" instead of the current dir.But if there is no indicated file, we'll open
" the current dir.
augroup EnterVim
autocmd!
autocmd VimEnter * NERDTree %:p:h
autocmd VimEnter * wincmd w
"autocmd VimEnter * TlistToggle
"autocmd VimEnter * call AccentDemo()
autocmd FileWritePost * TlistUpdate
"autocmd BufRead * Autoread 3
"autocmd VimLeave * :!cp ~/.vimrc ~/.vimrc.bak
"autocmd VimLeave * :!rm -rf ~/.vimrc
augroup END
"}}}auto command end
"plugin install{{{
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tomasr/molokai'
Plugin 'vim-scripts/phd'
Plugin 'morhetz/gruvbox'
Plugin 'Lokaltog/vim-powerline'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'derekwyatt/vim-fswitch'
Plugin 'kshenoy/vim-signature'
Plugin 'vim-scripts/BOOKMARKS--Mark-and-Highlight-Full-Lines'
"Plugin 'MattesGroeger/vim-bookmarks'
Plugin 'majutsushi/tagbar'
Plugin 'vim-scripts/indexer.tar.gz'
Plugin 'vim-scripts/DfrankUtil'
Plugin 'vim-scripts/vimprj'
Plugin 'vim-scripts/ctags.vim'
Plugin 'vim-scripts/a.vim'
Plugin 'vim-scripts/auto_autoread.vim'
Plugin 'dyng/ctrlsf.vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'scrooloose/nerdcommenter'
Plugin 'vim-scripts/DrawIt'
Plugin 'SirVer/ultisnips'
"Plugin 'Valloric/YouCompleteMe'
Plugin 'derekwyatt/vim-protodef'
"Plugin 'scrooloose/nerdtree'
Plugin 'TonyCode2012/nerdtree'
Plugin 'fholgado/minibufexpl.vim'
Plugin 'gcmt/wildfire.vim'
Plugin 'sjl/gundo.vim'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'suan/vim-instant-markdown'
"Plugin 'lilydjwg/fcitx.vim'
Plugin 'mileszs/ack.vim'
Plugin 'vim-scripts/ag.vim'
Plugin 'vim-scripts/taglist.vim'
Plugin 'will133/vim-dirdiff'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'
Plugin 'iamcco/markdown-preview.vim'
Plugin 'Shougo/neocomplete.vim'
Plugin 'vim-scripts/cmd.vim'
"Plugin 'Xuyuanp/nerdtree-git-plugin'
"Plugin 'tpope/vim-surround'
call vundle#end()
filetype plugin indent on
"}}}plugin install end
"plugin configuration{{{
""" configure fugitive
nnoremap <Leader>gsd :Gsdiff<CR>
nnoremap <Leader>gvd :Gvdiff<CR>
""" multiple cursor configuration
" deal with multiple cursor conflict
let g:multi_cursor_use_default_mapping=0
" quick replacement
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<M-p>'
let g:multi_cursor_skip_key='<M-k>'
let g:multi_cursor_quit_key='<Esc>'
" mark down
let g:mkdp_path_to_chrome="/usr/bin/google-chrome-stable"
" jump betwwn .h and .c files
"nnoremap <Leader>h :A<CR>
""" nerdtree configuration
nnoremap <Leader>o :NERDTreeToggle<CR>
" hide/show MiniBufExploer
map <Leader>bl :MBEToggle<cr>
" tab relation
nnoremap <Leader>tn :tabc<cr>
nnoremap <Leader>tc :tabc<cr>
nnoremap <Leader>to :tabo<cr>
nnoremap <Leader>ts :tabs<cr>
nnoremap <Leader>tp :tabp<cr>
nnoremap <Leader>tn :tabp<cr>
" buffer switch
"map <c-tab> :MBEbn<cr>
"map <c-s-tab> :MBEbp<cr>
"set fileencodings=utf-8,ucs-bom,cp936,gbk,gb2312,big5,latin1
""" set color
set t_Co=256
set background=dark
"colorscheme solarized
"colorscheme molokai
"colorscheme phd
colorscheme gruvbox
let g:gruvbox_contrast_dark='hard'
"let g:gruvbox_hls_cursor='aqua'
""" signature configuration
let g:SignatureMap = {
\ 'Leader' : "m",
\ 'PlaceNextMark' : "m,",
\ 'ToggleMarkAtLine' : "m.",
\ 'PurgeMarksAtLine' : "m-",
\ 'DeleteMark' : "dm",
\ 'PurgeMarks' : "mda",
\ 'PurgeMarkers' : "m<BS>",
\ 'GotoNextLineAlpha' : "']",
\ 'GotoPrevLineAlpha' : "'[",
\ 'GotoNextSpotAlpha' : "`]",
\ 'GotoPrevSpotAlpha' : "`[",
\ 'GotoNextLineByPos' : "]'",
\ 'GotoPrevLineByPos' : "['",
\ 'GotoNextSpotByPos' : "mn",
\ 'GotoPrevSpotByPos' : "mp",
\ 'GotoNextMarker' : "[+",
\ 'GotoPrevMarker' : "[-",
\ 'GotoNextMarkerAny' : "]=",
\ 'GotoPrevMarkerAny' : "[=",
\ 'ListLocalMarks' : "lm",
\ 'ListLocalMarkers' : "m?"
\ }
"let g:Powerline_colorscheme='solarized256'
syntax enable
syntax on
syntax keyword cppSTLtype initializer_list
filetype indent on
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
""" indent configuration
let g:indent_guides_enable_on_vim_startup=1
let g:indent_guides_start_level=2
let g:indent_guides_guide_size=1
:nmap <silent> <Leader>i <Plug>IndentGuidesToggle
set foldmethod=indent
"set foldmethod=syntax
set nofoldenable
" switch between .c/.cpp and .h file
nmap <silent> <Leader>sw :FSHere<cr>
" use ctrlsf.vim to search key words in project
"set runtimepath^=~/.vim/bundle/ag.vim
" search
let g:ctrlsf_ackprg='ag'
nnoremap <Leader>sh *
nnoremap <Leader>su :execute "/".expand("<cWORD>")<CR>
nnoremap <Leader>sp :CtrlSF<CR>
nnoremap <Leader>ss :Ag! <cword> '%:p:h'<CR>
function! Replace(confirm, wholeword, replace)
wa
let flag = ''
if a:confirm
let flag .= 'gec'
else
let flag .= 'ge'
endif
let search = ''
if a:wholeword
let search .= '\<' . escape(expand('<cword>'), '/\.*$^~[') . '\>'
else
let search .= expand('<cword>')
endif
let replace = escape(a:replace, '/\&~')
execute 'argdo %s/' . search . '/' . replace . '/' . flag . '| update'
endfunction
nnoremap <Leader>R :call Replace(0, 0, input('Replace '.expand('<cword>').'with: '))<CR>
nnoremap <Leader>rw :call Replace(0, 1, input('Replace '.expand('<cword>').'with: '))<CR>
nnoremap <Leader>rc :call Replace(1, 0, input('Replace '.expand('<cword>').'with: '))<CR>
nnoremap <Leader>rcw :call Replace(1, 1, input('Replace '.expand('<cword>').'with: '))<CR>
nnoremap <Leader>rwc :call Replace(1, 1, input('Replace '.expand('<cword>').'with: '))<CR>
""" YCM configuration
" syntax definition and declaration jump
nnoremap <leader>gc :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gd :YcmCompleter GoToDefinition<CR>
" completition windown configuration
highlight Pmenu ctermfg=2 ctermbg=White guifg=#005f87 guibg=#EEE8D5
highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
let g:ycm_complete_in_comments=1
let g:ycm_confirm_extra_conf=0
let g:ycm_collect_identifiers_from_tags_files=1
"set tags+=/data/misc/software/misc./vim/stdcpp.tags
inoremap <leader>; <C-x><C-o>
set completeopt-=preview
let g:ycm_min_num_of_chars_for_completion=1
let g:ycm_cache_omnifunc=0
let g:ycm_seed_identifiers_with_syntax=1
" use OmniCppComplete function
let OmniCpp_DefaultNamespaces = ["_GLIBCXX_STD"]
set tags+=/ws/yaoz/tools/stdcpp.tags
" use neocomplete
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_auto_select = 1
"}}}plugin configuration end
"function! AccentDemo()
" let keys = ['a','b','c','d','e','f','g','h']
" for k in keys
" call airline#parts#define_text(k, k)
" endfor
" call airline#parts#define_accent('a', 'red')
" call airline#parts#define_accent('b', 'green')
" call airline#parts#define_accent('c', 'blue')
" call airline#parts#define_accent('d', 'yellow')
" call airline#parts#define_accent('e', 'orange')
" call airline#parts#define_accent('f', 'purple')
" call airline#parts#define_accent('g', 'bold')
" call airline#parts#define_accent('h', 'italic')
" let g:airline_section_a = airline#section#create(keys)
"endfunction