-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_vimrc
More file actions
322 lines (253 loc) · 7.2 KB
/
_vimrc
File metadata and controls
322 lines (253 loc) · 7.2 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
""""""""""""""""""""""""""""""""""
" @ bbn' vim rc
"
" Author: maxbbn(qipbbn@gmail.com)
" Website: http://www.maxbbn.com
" Since: 2011-01-08
" Last Modified: 2011-01-08
"
""""""""""""""""""""""""""""""""""
" 获取当前目录
func! GetPWD()
return substitute(getcwd(), "", "", "g")
endf
func! MySys()
return "linux"
endf
" 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 editing of the .vimrc
map <leader>e :e! ~/.vim/_vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vim/_vimrc
" 行控制
set linebreak " 英文单词在换行时不被截断
set nocompatible " 设置不兼容VI
set wrap " 设置自动折行
" 保留历史记录
set history=700
" 标签页
set tabpagemax=15 " 最多15个标签
set showtabline=2 " 总是显示标签栏
" 关闭遇到错误时的声音提示
set noerrorbells
set novisualbell
set t_vb= " close visual bell
" 行号和标尺
set ruler " 显示标尺
set number " 行号
set rulerformat=%15(%c%V\ %p%%%)
set cursorline
hi cursorline guibg=NONE gui=underline
"搜索
set hlsearch " 高亮显示搜索的内容
set noincsearch " 关闭显示查找匹配过程
set magic "Set magic on, for regular expressions
" 命令行于状态行
set cmdheight=1 " 设置命令行的高度
set laststatus=2 " 始终显示状态行
set stl=\ [File]\ %F%m%r%h%y[%{&fileformat},%{&fileencoding}]\ %w\ \ [PWD]\ %r%{GetPWD()}%h\ %=\ [Line]%l/%L\ %=\[%P] "设置状态栏的信息
" 制表符(设置所有的tab和缩进为4个空格)
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab "使用空格来替换tab
set smarttab
" 状态栏显示目前所执行的指令
set showcmd
" 缩进
set autoindent " 设置自动缩进
set smartindent " 设置智能缩进
" 插入模式下使用 <BS>、<Del> <C-W> <C-U>
set backspace=indent,eol,start
set mouse=a
" 自动完成
set complete=.,w,b,k,t,i
set completeopt=longest,menu " 只在下拉菜单中显示匹配项目,并且会自动插入所有匹配项目的相同文本
" 代码折叠
set foldmethod=indent
" 带有如下符号的单词不要被换行分割
set iskeyword+=_,$,@,%,#,-
" 显示tab和空格
set list
" 设置tab和空格样式
set listchars=tab:\|\ ,nbsp:%,trail:-
" 设定行首tab为灰色
highlight LeaderTab guifg=#666666
" 匹配行首tab
match LeaderTab /\t/
set wildmenu "打开 wildmenu 选项,启动具有菜单项提示的命令行自动完成。
set matchpairs=(:),{:},[:],<:>
set whichwrap=b,s,<,>,[,]
" 搜索时智能大小写
"set ignorecase
set smartcase
"
set clipboard+=unnamed
"系统剪切板
vnoremap <c-c> "+y
noremap <S-Del> "+p
inoremap <S-Del> <esc>"+pa
vnoremap <S-Del> d"+P
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
"Persistent undo
try
if MySys() == "windows"
set undodir=C:\Windows\Temp
else
set undodir=~/.vim_runtime/undodir
endif
set undofile
catch
endtry
" Set hidden to undo buffer
set hidden
" =====================
" 默认为 UTF-8 编码
" =====================
if has("multi_byte")
set encoding=utf-8
" English messages only
"language messages zh_CN.utf-8
if has('win32')
language english
let &termencoding=&encoding " 处理consle输出乱码
endif
set fencs=utf-8,gbk,chinese,latin1
set formatoptions+=mM
set nobomb " 不使用 Unicode 签名
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)'
set ambiwidth=double
endif
else
echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"
endif
" =====================
" 主题配色
" =====================
if has('syntax')
" 保证语法高亮
syntax on
if has('gui_running')
colorscheme zenburn
let g:colors_name="zenburn"
endif
" 默认编辑器配色
" au BufNewFile,BufRead,BufEnter,WinEnter * colo yytextmate
" 各不同类型的文件配色不同
"au BufNewFile,BufRead,BufEnter,WinEnter *.wiki colo moria
au BufNewFile,BufRead *.less set filetype=less
endif
" =====================
" 图形界面
" =====================
if has('gui_running')
"set guioptions=mcr " 只显示菜单
"set guioptions= " 隐藏全部的gui选项
"set guioptions+=r " 显示gui右边滚动条
"Toggle Menu and Toolbar 使用F2隐藏/显示菜单
set guioptions-=m
set guioptions-=T
map <silent> <F3> :if &guioptions =~# 'T' <Bar>
\set guioptions-=T <Bar>
\set guioptions-=m <bar>
\else <Bar>
\set guioptions+=T <Bar>
\set guioptions+=m <Bar>
\endif<CR>
if has("unix") && !has('gui_macvim')
set guifont=Courier\ 11\ Pitch\ 12
endif
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map space to / (search) and c-space to ? (backgwards search)
" map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Smart way to move btw. windows
"map <C-j> <C-W>j
"map <C-k> <C-W>k
"map <C-h> <C-W>h
"map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,300 bd!<cr>
" Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
" Tab configuration
map <C-t> :tabnew<cr>
map <C-k> :tabclose<cr>
map <C-Tab> :tabnext<cr>
map <right> :tabnext<cr>
map <left> :tabprevious<cr>
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
" =====================
" 插件配置
" =====================
"NERD_commenter
let NERDShutUp = 1
map <c-h> ,c<space>
"neo complomplache
let g:neocomplcache_min_syntax_length = 3
inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
"web indent
let g:js_indent_log = 0
"JSLint
if has('gui_running')
let g:JSLintHighlightErrorLine = 0
else
let g:JSLintHighlightErrorLine = 0
endif
" Gist
let g:gist_clip_command = 'pbcopy'
call pathogen#infect()
"NERD_tree
autocmd vimenter * if !argc() | NERDTree | endif