-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
304 lines (245 loc) · 7.76 KB
/
.vimrc
File metadata and controls
304 lines (245 loc) · 7.76 KB
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
au BufRead,BufNewFile grepresult call GrepresultInit()
function! GrepresultInit()
setlocal ft=grepresult
if line('.') != 1
let currentLine = line('.')
let currentCol = col('.')
call cursor(1,1)
exe "syn keyword searchKEY" expand("<cword>")
call cursor(currentLine,currentCol)
else
exe "syn keyword searchKEY" expand("<cword>")
endif
endfunction
function! ISgrepresult()
if expand("%:t") == "grepresult"
return 1
else
return 0
endif
endfunction
function! GrepResultEnter()
let words = split(getline('.'), ':')
if get(words, 1) != 0
exec "vi " words[0]
exec words[1]
endif
endfunction
nmap <expr> <CR> ISgrepresult()?":call GrepResultEnter()<CR>":"<CR>"
"nmap <CR> :call PressEnter()<CR>
vmap <CR> y/<C-R>"<CR>
vmap <C-R> y:! <C-R>"<CR>
let g:load_doxygen_syntax=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Set mapleader
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Get out of VI's compatible mode.
set nocompatible
" Enable filetype plugin
filetype plugin indent on
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Fast quit
nmap <leader>q :qa<cr>
" Fast loading .vimrc file
nmap <leader>s :source ~/.vimrc<cr>
"""
" 设置语言
set encoding=utf-8
set termencoding=utf-8
"set fileencoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set ruler "Always show current position
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
"多buffer切换不需要保存
set hidden
set dy=lastline,uhex "display(dy)
set backspace=indent,eol,start
set nu "number(nu), nonumber(nonu)行号
set laststatus=2
set statusline=%<%f%h%m%r%=%{strftime(\"%I:%M:%S\ \%p,\ %a\ %b\ %d,\ %Y\")}\ \ \ %b\ 0x%B\ \ \ \ \ %l,%c%V\ \ \ \ %P
"set statusline=2
if &term != "xterm"
" SecureCRT versions prior to 6.1.x do not support 4-digit DECSET
" let &t_ti = "\<Esc>[?1049h"
" let &t_te = "\<Esc>[?1049l"
" Use 2-digit DECSET instead
let &t_ti = "\<Esc>[?47h"
let &t_te = "\<Esc>[?47l"
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files and backups
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
"设置缩进
set ai "autoindent(ai)
set cindent "C语言缩进
set shiftwidth=4 "设置缩进长度
set tabstop=4 "设置tab长度
set expandtab "设置空格替代tab
set smarttab "行首tab的四个空格可以整个删除
"M$ / Linux
set clipboard+=unnamed
"GUI
if has("gui_running")
au GUIEnter * simalt ~x
set go= "无菜单,无任务栏
endif
"nmap t i<tab><esc>l
nmap <leader>1 1gt
nmap <leader>2 2gt
nmap <leader>3 3gt
nmap <leader>4 4gt
nmap <leader>5 5gt
nmap <leader>6 6gt
nmap <leader>7 7gt
nmap <leader>8 8gt
nmap <leader>9 9gt
nmap <leader>d :bd<CR>
nmap <leader>p :bp<CR>
nmap <leader>n :bn<CR>
"配色方案
colo desert "ColorScheme(colo)
"colo ChocolateLiquor
"colo evening
"colo darkZ
"语法高亮
syntax enable
syntax on
"Search
set magic " Set magic on, for regular expressions
set hlsearch " 高亮搜索结果
"set incsearch " 增量搜索
"Automatically remove trailing spaces when saving a file.
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
" Python 文件的一般设置,比如不要 tab 等
autocmd FileType python setlocal et | setlocal sta | setlocal sw=4
"pydiction
autocmd FileType python set complete+=k~/.vim/doc/complete-dict
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Parenthesis/bracket expanding
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"inoremap ( ()<ESC>ha
"inoremap ) <c-r>=ClosePair(')')<CR>
"inoremap { {<CR>}<ESC>k$a<CR>
"inoremap } <c-r>=ClosePair('}')<CR>
"inoremap [ []<ESC>i
"inoremap ] <c-r>=ClosePair(']')<CR>
"inoremap < <><ESC>i
"inoremap > <c-r>=ClosePair('>')<CR>
"function! ClosePair(char)
" if getline('.')[col('.') - 1] == a:char
" return "\<Right>"
" else
" return a:char
" endif
"endf
"Split
nmap <silent> <leader>sp :split<CR>
nmap <silent> <leader>vs :vsplit<CR>
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
nmap <silent> [ :vertical res -1<CR>
nmap <silent> ] :vertical res +1<CR>
nmap <silent> _ :res -1<CR>
nmap <silent> + :res +1<CR>
nmap <leader>hm <C-w>_
nmap <leader>vm <C-w>\|
nmap <leader>eq <C-w>=
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
"Buffer
"nmap <right> :bn<cr>
"nmap <left> :bp<cr>
"Emacs-mode mapping
"map <expr> <C-e> pumvisible()?"\<C-E>":"\<End>"
"map! <expr> <C-e> pumvisible()?"\<C-E>":"\<End>"
"<C-e> <End>
"map <C-a> <Home>
"map! <C-a> <Home>
cmap <C-b> <Left>
cmap <C-f> <Right>
imap <C-u> <esc>d^xi
imap <C-k> <esc>ld$a
"imap <C-p> <Up>
"imap <C-n> <Down>
"imap <C-b> <Left>
"imap <C-f> <Right>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Switch wrap mode
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:wrapmode=1
nmap <silent> <F3> :call ToggleWrapMode()<CR>
function! ToggleWrapMode()
if g:wrapmode == 0
set wrap
let g:wrapmode=1
else
set nowrap
let g:wrapmode=0
endif
endfunction
"nmap <leader>sc yaw:ConqueTermSplit bash<CR>sc<esc>p $PWD<CR>
nmap <leader>sc :!echo <C-R>=expand("<cword>")<CR> > /tmp/grepresult;sc <C-R>=expand("<cword>")<CR> $PWD >> /tmp/grepresult<CR><CR>:split<CR><C-J>:vi /tmp/grepresult<CR>:syn keyword searchKEY <C-R>=expand("<cword>")<CR><CR>
"command -nargs=0 REF :!sh refresh.sh<CR>
"------------For Plugins
"FuzzyFinder
map <leader>tf :FufTaggedFile<CR>
map <leader>file :FufFile<CR>
"BufExplorer
map <F6> :BufExplorer<cr>
"cscope
nmap <C-g> :cs f g <C-R>=expand("<cword>")<CR><CR>
nmap <leader>g :scs f g <C-R>=expand("<cword>")<CR><CR>
nmap <leader>e :cs f e <C-R>=expand("<cword>")<CR><CR>
nmap <C-y> :cs f c <C-R>=expand("<cword>")<CR><CR>
nmap <leader>i :cs f f <C-R>=expand("<cfile>")<CR><CR>
"taglist
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
"map <silent> <F9> :TlistToggle<cr>
"NERDTree
map <F4> :NERDTreeToggle<cr>
let g:NERDTreeHighlightCursorline = 0
let g:winManagerWindowLayout = "TagList"
let g:winManagerWidth = 30
nmap <silent> <F5> :WMToggle<cr>
"Doxygen
nmap <F2>s i/**< */<ESC>hhi
imap <F2>s /**< */<ESC>hhi
nmap <F2>3 i///
imap <F2>3 ///
"srcexpl
map <F8> :SrcExplToggle<CR><CR>
"智能补全
set completeopt=longest,menu
inoremap <expr> <CR> pumvisible()?"<C-Y>":"<CR>"
inoremap <expr> <C-J> pumvisible()?"<PageDown><C-N><C-P>":"<C-X><C-O>"
inoremap <expr> <C-K> pumvisible()?"<PageUp><C-P><C-N>":"<C-K>"
inoremap <expr> <C-U> pumvisible()?"<C-E>":"<C-U>"
"vimgdb
set previewheight=12 " set gdb window initial height
"MRU
nmap <leader>u :MRU<CR>
"cscope
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif