-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
378 lines (310 loc) · 11.6 KB
/
.vimrc
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
" 文件编码
set fileencodings=ucs-bom,utf-8,gbk,cp936 ",gb18030,big5,latin1 "文件编码检查
set encoding=utf-8 "vim内部编码
set fileencoding=utf-8 "保存时,文件的编码格式
set termencoding=utf-8 "终端编码
language messages zh_CN.UTF-8 "提示信息中文
"source $VIMRUNTIME/vimrc_example.vim
set nocompatible " 关闭 vi 兼容模式
syntax on " 自动语法高亮
"filetype plugin indent on " 开启插件
"filetype on " 自动检查文件类型
" 显示
colorscheme rolin " 设定配色方案
set number " 显示行号
"set cursorline " 突出显示当前行
"set wrap " 设置折行
"set linebreak " 设置智能判断折行
set ruler " 打开状态栏标尺
set guioptions-=T " 隐藏工具栏
set guioptions-=m " 隐藏菜单栏
"set list
"set listchars=tab:¦\ ,eol:¬ " 设置tab显示和末尾显示
" 缩进
set expandtab " 使用space代替tab.
set smarttab " 根据文件中其他地方的缩进空格个数来确定一个 tab 是多少个空格
set smartindent " 开启新行时使用智能自动缩进
set shiftwidth=2 " 每一级缩进是多少个空格
set softtabstop=2 " 使得按退格键时可以一次删掉 4 个空格
set tabstop=2 " 设定 tab 长度
set autoindent " Auto indent
set cindent " C-style indeting
" 文件和目录
set nobackup " 覆盖文件时不备份
set backupcopy=yes " 设置备份时的行为为覆盖
set autochdir " 自动切换当前目录为当前文件所在的目录
" 搜索
set ignorecase "smartcase " 搜索忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感
set nowrapscan " 禁止在搜索到文件两端时重新搜索
set incsearch " 输入搜索内容时就显示搜索结果
set hlsearch " 搜索时高亮显示被找到的文本
" 声音
set noerrorbells " 关闭错误信息响铃
set novisualbell " 关闭使用可视响铃代替呼叫
set t_vb= " 置空错误铃声的终端代码
" 折叠
"set foldenable " 开始折叠
"set foldmethod=indent " 设置语法折叠
"set foldcolumn=0 " 设置折叠区域的宽度
"setlocal foldlevel=1 " 设置折叠层数
"set completeopt=longest,menu " 即时显示自动提示
set foldclose=all " 设置为自动关闭折叠
" 其他
"set showmatch " 插入括号时,短暂地跳转到匹配的对应括号
"set matchtime=2 " 短暂跳转到匹配括号的时间
set magic " 开启:$.*^之外其他元字符都要加反斜杠;关闭:$^之外其他元字符都要加反斜杠。
"set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存
set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符
"set cmdheight=1 " 设定命令行的行数为 1
set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)
" mac and windows 区别设置
if (has("win32") || has("win64") || has("win32unix"))
source $VIMRUNTIME/mswin.vim " 载入window配置
set fileformat=dos
set fileformats=dos
set guifontwide=YouYuan:h10:cGB2312
set guifont=Monaco:h10
" 快捷载入vimrc
nmap <leader>s <ESC>:source ~/.vimrc<CR>
" 快捷打开.vimrc
nmap <leader>z <ESC>:vnew ~/.vimrc<CR>
"let &shell='C:\Windows\System32\cmd.exe'
if &shell=~#'bash$'
set shell=$COMSPEC " sets shell to correct path for cmd.exe
endif
else
set fileformat=unix
set fileformats=unix
set guifont=Monaco:h14
" mac替换ESC
inoremap ` <ESC>
" 快捷载入vimrc
nmap <leader>s <ESC>:source ~/.vim/.vimrc<CR>
" 快捷打开.vimrc
nmap <leader>z <ESC>:vnew ~/.vim/.vimrc<CR>
" 转换结尾字符
map <leader>w :%s /\r\n/\r/g<cr>
endif
" ------------------各种快捷键------------------
" 删除行尾空白
map <leader>b :%s/[ \t\r]\+$//g<cr>
" 把文件内的tab转换成空格
nmap <leader>r :%retab!<CR>
" 高亮当前列
nmap <Leader>h :call SetColorColumn()<CR>
" IndentGuides
" nmap <Leader>i :call indent_guides#toggle()<CR>
" TODO 检测
nmap <Leader>t :vim /TODO/g ./*<CR>
" NERDTree快捷键
map nt :NERDTree<CR>
map <Leader>j :call JsBeautify()<cr>
"map <Leader>x :call JsonBeautify()<cr>
"map <Leader>x :call JsxBeautify()<cr>
"map <Leader>x :call HtmlBeautify()<cr>
"map <Leader>x :call CSSBeautify()<cr>
map <Leader>c :noh<cr>
" Mou打开
" nmap <leader>m :MouOpen<CR>
" 用空格键来开关折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" for ruanyl/vim-fixmyjs
noremap <Leader>f :Fixmyjs<CR>
" 上下左右方向键切换窗口
nmap <LEFT> <C-w>h
nmap <DOWN> <C-w>j
nmap <UP> <C-w>k
nmap <RIGHT> <C-w>l
" 插入匹配括号
inoremap ( ()<LEFT>
inoremap [ []<LEFT>
"inoremap { {}<LEFT><CR><ESC>O
inoremap " ""<LEFT>
inoremap ' ''<LEFT>
inoremap < <><LEFT>
" 各种设置, 自动运行
" 高亮行尾空白
highlight tailBlack ctermbg=red guibg=#990000
match tailBlack /\(\S\+\)\@<=[ \t\r]\+$/
" 高亮80字符限制
" highlight overLength ctermbg=red guibg=#792929
" 2match overLength /\(.\{80}\)\@<=.*\S\+/
" ----------------------------bundles----------------------------
" My bundles here:
set nocompatible " be iMproved
filetype off " required!
if (has("win32") || has("win64") || has("win32unix"))
set rtp+=$HOME/vimfiles/bundle/Vundle.vim/
call vundle#begin('$HOME/vimfiles/bundle/')
else
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin('~/.vim/bundle/')
endif
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
" vim-scripts repos
" utility
Plugin 'pathogen.vim'
"Plugin 'vim-mou'
"Plugin 'vim-coffee-script'
Plugin 'mattn/emmet-vim'
"Plugin 'Indent-Guides'
"Plugin 'Colorizer--Brabandt' "disabled
"Plugin 'surround.vim'
"Plugin 'VimIM'
"Plugin 'vimcdoc'
"Plugin 'listtag'
"Plugin 'Tagbar'
"Plugin 'Conque-Shell'
"Plugin 'Command-T'
"Plugin 'powerline/powerline'
"Plugin 'ternjs/tern_for_vim'
"Plugin 'Valloric/YouCompleteMe'
Plugin 'ctrlpvim/ctrlp.vim'
"Tool
Plugin 'mru.vim'
Plugin 'The-NERD-tree'
Plugin 'vim-syntastic/syntastic'
Plugin 'Chiel92/vim-autoformat'
Plugin 'maksimr/vim-jsbeautify'
"Dash
"Plugin 'rizzatti/funcoo.vim'
"Plugin 'rizzatti/dash.vim'
"indent and syntax
Plugin 'pangloss/vim-javascript'
"Plugin 'axiaoxin/vim-json-line-format'
Plugin 'posva/vim-vue'
Plugin 'ruanyl/vim-fixmyjs'
"indent
"Plugin 'indentpython.vim'
"Plugin 'Simple-Javascript-Indenter'
"Plugin 'jade.vim'
"Plugin 'JavaScript-Indent'
"Plugin 'html-improved-indentation'
"Plugin 'sh.vim'
"Plugin 'indenthtml.vim'
"syntax
Plugin 'leafgarland/typescript-vim'
"Plugin 'Sass'
"Plugin 'Markdown-syntax'
"Plugin 'jQuery'
"Plugin 'HTML5-Syntax-File'
"Plugin 'jelera/vim-javascript-syntax'
"Plugin 'othree/javascript-libraries-syntax.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" ------------------插件、变量设置------------------
" NERDTree
let g:NERDTreeWinSize=20
" IndentGuides
"let g:indent_guides_guide_size=1
"coffee配置
"let coffee_compile_vert = 1
"let coffee_watch_vert = 1
"先加载路径处理插件
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
" coffee即时编译
"autocmd BufWritePost *.coffee silent make!
"vim-mou 插件配置(mac)
"let g:mou_dir = "/Applications/Mou.app"
"powerline
"let g:Powerline_symbols = 'fancy'
" ruanyl/vim-fixmyjs
let g:fixmyjs_engine = 'eslint'
" for 'vim-syntastic/syntastic'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_loc_list_height = 10
" FOR DEBUG
"let g:syntastic_debug=3
let g:syntastic_debug=0
"let g:syntastic_javascript_checkers = ['eslint', 'jshint']
let g:syntastic_javascript_checkers = ['eslint']
"let g:used_javascript_libs = 'jquery,angularjs,backbone'
" 关闭语法检查
nmap <leader>d :SyntasticToggleMode<CR>
" find the root eslint config"
function! FindConfig(prefix, what, where)
let cfg = findfile(a:what, escape(a:where, ' ') . ';')
return cfg !=# '' ? ' ' . a:prefix . ' ' . shellescape(cfg) : ''
endfunction
autocmd FileType javascript let b:syntastic_javascript_eslint_args =
\ get(g:, 'syntastic_javascript_eslint_args', '') .
\ FindConfig('-c', '.eslintrc.json', expand('<afile>:p:h', 1))
" for eslint
let g:formatdef_eslint = '"SRC=eslint-temp-${RANDOM}.js; cat - >$SRC; eslint --fix $SRC >/dev/null 2>&1; cat $SRC | perl -pe \"chomp if eof\"; rm -f $SRC"'
let g:formatters_javascript = ['eslint']
let g:formatters_vue = ['eslint']
" for 'ctrlpvim/ctrlp.vim'
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.(git|hg|svn)|node_modules)$',
\ 'file': '\v\.(exe|so|dll)$',
\ }
" for 'pangloss/vim-javascript'
let g:javascript_plugin_jsdoc = 1
" for Plugin 'posva/vim-vue'
autocmd FileType vue syntax sync fromstart
" ------------------其他函数------------------
" 其他函数
" 高亮当前列函数
function! SetColorColumn()
let col_num = virtcol(".")
let cc_list = split(&cc, ',')
if count(cc_list, string(col_num)) <= 0
execute "set cc+=".col_num
else
execute "set cc-=".col_num
endif
endfunction
if (has("win32") || has("win64") || has("win32unix"))
set diffexpr=MyDiff()
function! MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
endif