Skip to content

Commit c869765

Browse files
author
zhuliting
authored
Update vimrc
1 parent add9315 commit c869765

File tree

1 file changed

+86
-33
lines changed

1 file changed

+86
-33
lines changed

config/vimrc

+86-33
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set tabstop=4
88
set shiftwidth=4
99
set expandtab
1010
set cindent
11+
set mps+=<:>
1112

1213
" 代码折叠
1314
set fdm=marker
@@ -40,6 +41,7 @@ set nu
4041
"set cursorline
4142
" 语法高亮度显示
4243
let python_highlight_all=1
44+
let go_highlight_all=1
4345
syntax on
4446

4547
" 显示括号配对情况
@@ -48,14 +50,14 @@ filetype off " required!
4850

4951
set completeopt=longest,menu
5052

51-
" bundle setting
53+
" bundle setting
5254
" git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
5355
" aptitude install vim-gui-common
5456
set rtp+=~/.vim/bundle/vundle/
5557
call vundle#begin()
5658

5759
" let Vundle manage Vundle
58-
" required!
60+
" required!
5961
Bundle 'gmarik/vundle'
6062
" 状态栏
6163
Bundle 'vim-airline/vim-airline'
@@ -82,14 +84,17 @@ Bundle 'jiangmiao/auto-pairs'
8284
Bundle 'vim-scripts/OmniCppComplete'
8385

8486
Bundle 'scrooloose/syntastic'
87+
let g:ycm_python_binary_path = '/usr/local/bin/python3'
8588
let g:ycm_show_diagnostics_ui = 0
8689
let g:syntastic_check_on_open = 1
8790
let g:syntastic_cpp_checkers = ['clang++']
8891
let g:syntastic_cpp_compiler = 'clang++'
8992
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
9093

94+
" git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe
95+
" git submodule update --init --recursive
96+
" cd ~/.vim/bundle/YouCompleteMe && ./install.py --go-completer --clang-completer
9197
Bundle 'Valloric/YouCompleteMe'
92-
" cd ~/.vim/bundle/YouCompleteMe && ./install.py --clang-completer
9398

9499
" 提示函数参数
95100
"Bundle 'vim-scripts/echofunc.vim'
@@ -103,6 +108,9 @@ Bundle 'STL-Syntax'
103108
"Bundle 'a.vim'
104109
"Bundle 'derekwyatt/vim-fswitch'
105110

111+
"去除行尾空格
112+
Bundle 'bronson/vim-trailing-whitespace'
113+
106114
" Bundle 'c.vim'
107115
Bundle 'ctags.vim'
108116
Bundle 'taglist.vim'
@@ -118,21 +126,35 @@ Bundle 'surround.vim'
118126
" non-GitHub repos
119127
" CommandT
120128
Bundle 'git://git.wincent.com/command-t.git'
121-
" cd ~/.vim/ruby/command-t && ruby extconf.rb && make
129+
" cd ~/.vim/bundle/command-t/ruby/command-t && ruby ext/command-t/extconf.rb && rake make
122130
" 命令:
123131
" CommandTBuffer
124132
" CommandT
125-
"
133+
"
126134

127135
" gen tags
128136
"Bundle 'vim-scripts/DfrankUtil'
129137
"Bundle 'vim-scripts/vimprj'
130138
"Bundle 'vim-scripts/indexer.tar.gz'
131139

140+
Bundle 'Chiel92/vim-autoformat'
141+
142+
" go
143+
Bundle 'fatih/vim-go'
144+
Bundle 'vim-jp/vim-go-extra'
145+
Bundle 'dgryski/vim-godef'
146+
Bundle 'Blackrush/vim-gocode'
147+
Bundle 'zmb3/gogetdoc'
148+
Bundle 'majutsushi/tagbar'
149+
150+
" jump, reuse the current window
151+
let g:godef_split=0
152+
" brew install gotags
153+
132154
call vundle#end()
133155

134156
"leader映射为逗号“,”
135-
let mapleader = ","
157+
let mapleader = ","
136158

137159
"*****************************************************
138160
" taglist配置 *
@@ -155,10 +177,11 @@ let Tlist_WinWidth=30
155177
let Tlist_Exit_OnlyWindow=1
156178
"单击跳转
157179
let Tlist_Use_SingClick=1
180+
158181
" 自动打开taglist
159-
"let Tlist_Auto_Open=1
160-
"Tlist 打开关闭快捷键 fn + F9
161-
nnoremap <silent> <F9> :TlistToggle<CR>
182+
let Tlist_Auto_Open=1
183+
"Tlist 打开关闭快捷键 fn + F1
184+
nnoremap <silent> <F1> :TlistToggle<CR>
162185
let g:tagbar_autopreview = 1
163186

164187

@@ -191,14 +214,14 @@ let g:ycm_seed_identifiers_with_syntax=1
191214
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
192215
"打开vim时不再询问是否加载ycm_extra_conf.py配置
193216
let g:ycm_confirm_extra_conf=0
194-
let g:ycm_semantic_triggers = {'c' : ['->', '.'], 'objc' : ['->', '.'], 'ocaml' : ['.', '#'], 'cpp,objcpp' : ['->', '.', '::'], 'php' : ['->', '::'], 'cs,java,javascript,vim,coffee,python,scala,go' : ['.'], 'ruby' : ['.', '::']}
217+
let g:ycm_semantic_triggers = {'c' : ['->', '.'], 'objc' : ['->', '.'], 'ocaml' : ['.', '#'], 'cpp,objcpp' : ['->', '.', '::'], 'php' : ['->', '::'], 'cs,java,javascript,vim,coffee,python,scala,go' : ['.']}
195218

196219

197220
" Look for tag def in a "tags" file in the dir of the current file, then for
198221
" that same file in every folder above the folder of the current file, until the
199222
" root.
200223
set tags=./tags;/
201-
" gen systags:
224+
" gen systags:
202225
" ctags -R --fields=+aiKlSz --extra=+q --c++-kinds=+px .
203226
"set notagbsearch
204227

@@ -229,7 +252,7 @@ nmap <leader>l <Plug>(easymotion-overwin-line)
229252

230253
" F12 run python
231254
map <F12> :!/usr/bin/python %
232-
map <F9> :!~/go/bin/go run %
255+
map <F11> :!~/go/bin/go run %
233256
234257

235258
filetype plugin indent on
@@ -244,14 +267,12 @@ if has("autocmd")
244267
autocmd BufRead *.txt set tw=78
245268
" When editing a file, always jump to the last cursor position
246269
autocmd BufReadPost *
247-
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
248-
\ exe "normal g'\"" |
249-
\ endif
270+
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
271+
\ exe "normal g'\"" |
272+
\ endif
250273
endif
251274
" set bg=dark
252275

253-
filetype plugin on
254-
255276
" highlight setting
256277
"let c_no_curly_error=1
257278
let g:ophigh_color = 226
@@ -260,17 +281,40 @@ let g:cpp_member_variable_highlight = 1
260281
let g:cpp_experimental_simple_template_highlight = 1
261282
let g:cpp_class_scope_highlight = 1
262283

284+
""****************************************************
285+
" auto format *
286+
"*****************************************************
287+
"clang-format for formating cpp code
288+
nnoremap <leader>c :call FormatCode()<cr><cr>
289+
vnoremap <leader>c :call FormatCode()<CR><CR>
290+
"nnoremap <leader>lf :call FormatCode("LLVM")<cr>
291+
"vnoremap <leader>lf :call FormatCode("LLVM")<cr>
292+
let g:autoformat_verbosemode = 1
293+
func FormatCode()
294+
let firstline=line(".")
295+
let lastline=line(".")
296+
" Visual mode
297+
if exists(a:firstline)
298+
firstline = a:firstline
299+
lastline = a:lastline
300+
endif
301+
let g:formatdef_clangformat = "'clang-format --lines='.a:firstline.':'.a:lastline.' --assume-filename='.bufname('%').' -style=file'"
302+
let formatcommand = ":" . firstline . "," . lastline . "Autoformat"
303+
exec formatcommand
304+
endfunc
263305

264306
" ***************python endent***************
307+
filetype plugin on
308+
265309
function! SET_PYTHON_IDENT()
266-
set shiftwidth=2
267-
set softtabstop=2
268-
set tabstop=2
269-
set backspace=2
270-
set smarttab
271-
set cursorcolumn
310+
set shiftwidth=2
311+
set softtabstop=2
312+
set tabstop=2
313+
set backspace=2
314+
set smarttab
315+
set cursorcolumn
272316
endfunction
273-
au FileType python,ruby,go :call SET_PYTHON_IDENT()
317+
au FileType python,go :call SET_PYTHON_IDENT()
274318
au FileType python set omnifunc=pythoncomplete#Complete
275319

276320
" Encoding related
@@ -284,23 +328,27 @@ set fileencoding=utf-8
284328
set t_Co=256
285329
"set background=dark
286330
set background=light
287-
"colorscheme monokai
331+
" colorscheme monokai
288332
"colorscheme molokai
289333
" 暗色调主题,适合夜间
290-
colorscheme colorsbox-stnight
334+
colorscheme colorsbox-stnight
335+
"colorscheme colorsbox-steighties
291336
"colorscheme colorsbox-faff
292337
"colorscheme colorsbox-greenish
293338
" colorscheme colorsbox-material
294-
"colorscheme colorsbox-stblue
295-
"colorscheme colorsbox-stbright
296-
"colorscheme colorsbox-steighties
339+
"colorscheme colorsbox-stblue
340+
"colorscheme colorsbox-stbright
297341
" colorscheme wombat256
298342

299343
" 显示状态栏
300344
set laststatus=2
301345
" 设置状态栏主题风格
302-
let g:Powerline_colorscheme='molokai256'
303-
let g:airline_theme = 'badwolf'
346+
let g:Powerline_colorscheme='monokai256'
347+
let g:airline_theme = 'badwolf'
348+
349+
"显示行尾空格
350+
highlight WhitespaceEOL ctermbg=red guibg=red
351+
match WhitespaceEOL /"s"+$/
304352

305353
" Fast saving
306354
"前面leader为逗号“,”
@@ -310,6 +358,10 @@ noremap <leader>q :q!<cr>
310358
noremap <leader>x :x<cr>
311359
inoremap <leader>x <esc>:x<cr>
312360
361+
362+
" 去除行尾空格快捷键
363+
map <leader><space> :FixWhitespace<cr>
364+
313365
"上、下方向键
314366
nmap j gj
315367
nmap k gk
@@ -321,14 +373,15 @@ noremap <leader>t :CommandT<cr>
321373
noremap <leader>s :vs<cr>
322374
noremap <leader>p :sp<cr>
323375
376+
noremap <leader>d :<c-d><cr>
377+
noremap <leader>u :<c-u><cr>
378+
324379
" 分屏多窗口跳转
325380
noremap zj <c-w>j
326381
noremap zk <c-w>k
327382
noremap zl <c-w>l
328383
noremap zh <c-w>h
329384
330-
331-
332385
" Ctrl + ] 多选择跳转
333386
"nmap <c-]> g<c-]>
334387

0 commit comments

Comments
 (0)