forked from zhupg/EnvConfiguration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
231 lines (186 loc) · 5.05 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
" Encoding
set encoding=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
set fileencodings=utf-8,ucs-bom,chinese
" File format
set fileformats=unix,dos
" Language
set langmenu=zh_CN.UTF-8
" File Type
set ffs=unix,dos,mac
" Hilight Syntax
syntax enable
syntax on
" Color
set background=dark
" Mouse
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" Line Number
set nu
" List
set nolist
set listchars=tab:\|\ ,nbsp:%,trail:-
highlight LeaderTab guifg=#666666
match LeaderTab /^\t/
" Highlight Search
set hlsearch
" Incremental Searching
set incsearch
" Highlight Line
set cursorline
hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
set cursorcolumn
hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
" Hilight {}
set showmatch
" Compatible
set nocompatible
" No backup
set nobackup
" No swap file
set noswapfile
" Softtabs, 4 spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
" Auto indent
set autoindent
set cindent
" Make it obvious where 80 characters is
set textwidth=80
set colorcolumn=+1
"Shortcuts Start
"map
map 9 $
map 0 ^
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Insert mode movement
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <c-h> <left>
inoremap <c-l> <right>
" Leader
let mapleader = ","
" expand tab to space
map <Leader>ts :%retab!<CR>
" Delete windows ^M
map <Leader>rm :%s/\r\m//g<CR>
" Index ctags from any project, including those outside Rails
map <Leader>ct :!ctags -R .<CR>
map <Leader>cc :!cscope -bRq<CR>
" Switch between the last two files
nnoremap <leader><leader> <c-^>
" Plugin Start
" Taglist
let Tlist_Show_One_File=0
let Tlist_File_Fold_Auto_Close=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_SingleClick=1
let Tlist_GainFocus_On_ToggleOpen=1
let Tlist_Process_File_Always=1
nmap <F8> :Tlist<CR>
" CSCOPE
nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
set cscopequickfix=s-,c-,d-,i-,t-,e-
function! AutoLoadCTagsAndCScope()
let max = 5
let dir = './'
let i = 0
let break = 0
while isdirectory(dir) && i < max
if filereadable(dir . 'cscope.out')
execute 'cs add ' . dir . 'cscope.out'
let break = 1
endif
if filereadable(dir . 'tags')
execute 'set tags =' . dir . 'tags'
let break = 1
endif
if break == 1
execute 'lcd ' . dir
break
endif
let dir = dir . '../'
let i = i + 1
endwhile
endf
nmap <F7> :call AutoLoadCTagsAndCScope()<CR>
" egrep
let g:EasyGrepMode = 2 " All:0, Open Buffers:1, TrackExt:2,
let g:EasyGrepCommand = 0 " Use vimgrep:0, grepprg:1
let g:EasyGrepRecursive = 1 " Recursive searching
let g:EasyGrepIgnoreCase = 1 " not ignorecase:0
let g:EasyGrepFilesToExclude = "*.bak, *~, cscope.*, tags, *.a, *.o"
" ctrlp
set runtimepath^=~/.vim/plugin/ctrlp.vim
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux"
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
" ToggleList
let g:lt_location_list_toggle_map = '<leader>l'
let g:lt_quickfix_list_toggle_map = '<leader>q'
" YankRing
let g:yankring_replace_n_pkey = '<leader>n'
" undotree
nnoremap <F2> :UndotreeToggle<cr>
if has("persistent_undo")
set undodir=~/.undodir/
set undofile
endif
" vim-airline plugin
set laststatus=2
" NERDTree plugin
let NERDTreeWinPos='left'
let NERDChristmasTree=0
let NERDTreeWinSize=40
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$', 'cscope*']
map <F5> :NERDTreeToggle<CR>
" Run commands that require an interactive shell
"nnoremap <Leader>r :RunInInteractiveShell<space>
" Run commands in new split buffer
nnoremap <Leader>r :ConqueTermSplit bash<CR>
" YouCompleteMe
let g:ycm_autoclose_preview_window_after_completion=1
nmap <leader>d :YcmCompleter GoToDefinitionElseDeclaration<CR>
" EasyMotion
" <Leader>f{char} to move to {char}
map <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
" neocomplete {{{
let g:neocomplete#data_directory = '~/.vim/tmp/neocomplete'
let g:acp_enableAtStartup = 1
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_auto_select = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#auto_completion_start_length = 2
" increase limit for tag cache files
let g:neocomplete#sources#tags#cache_limit_size = 16777216 " 16MB
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
" Local config
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif