forked from adam8157/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
265 lines (194 loc) · 5.79 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Be IMproved
set nocompatible
" Set backspace
set backspace=eol,start,indent
" Lines folding
set foldenable
set foldnestmax=1
set foldmethod=syntax
" Enable filetypes
filetype plugin indent on
" Set fileencodings
set fileencodings=ucs-bom,utf-8,gbk,big5
" Set complete options
set completeopt=longest,menu
" Set wild menu & mode
set wildmenu
set wildmode=longest:full,full
" Set key codes timeout
set ttimeoutlen=100
" Auto change current directory
set autochdir
" Use absolute paths in sessions
set sessionoptions-=curdir
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Backup
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable backup
set backup
" Set backup directory
set backupdir=~/.vim/backup
" Set swap file directory
set directory=~/.vim/swap,/tmp
" Keep more backups for one file
autocmd BufWritePre * let &backupext = strftime(".%m-%d-%H-%M")
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colors
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set colorscheme
colorscheme desert
" Enable syntax highlight
syntax on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Interface
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Show ruler
set ruler
" Dynamic title
set title
" Display line number
set number
" Always have a status line
set laststatus=2
" Allow to display incomplete line
set display=lastline
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Search
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable magic matching
set magic
" Show matching bracets
set showmatch
" Highlight search things
set hlsearch
" Ignore case when searching
set smartcase
set ignorecase
" Incremental match when searching
set incsearch
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto indent
set autoindent
" Smart indet
set smartindent
" Use hard tabs
set tabstop=8
set noexpandtab
set shiftwidth=8
" Break long lines
"set textwidth=78
" Set auto-formating
set formatoptions+=mM
" Config C-indenting
set cinoptions=:0,l1,t0,g0
" set textwidth for mail
autocmd FileType mail set textwidth=72
" Use soft tabs for python
autocmd FileType python set et sw=4 sts=4
" Use extension to set filetype
autocmd BufNewFile,BufRead *.md set filetype=markdown
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Ctags & Cscope
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto finding
set tags=tags;
" Use both cscope and ctag
set cscopetag
" Show msg when cscope db added
set cscopeverbose
" Use tags for definition search first
set cscopetagorder=1
" Use quickfix window to show cscope results
set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set Tagbar width
let tagbar_width = 32
" Use my own cscope mappings
let autocscope_menus = 0
" Use context to decide completion type
let SuperTabDefaultCompletionType = "context"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tab navigation
nnoremap tp :tabprevious<CR>
nnoremap tn :tabnext<CR>
nnoremap to :tabnew<CR>
nnoremap tc :tabclose<CR>
nnoremap gf <C-W>gf
" Move among windows
noremap <C-h> <C-W>h
noremap <C-j> <C-W>j
noremap <C-k> <C-W>k
noremap <C-l> <C-W>l
" Cscope mappings
nnoremap <C-w>\ :scs find c <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>s :scs find s <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>g :scs find g <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>d :scs find d <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>c :scs find c <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>t :scs find t <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>e :scs find e <C-R>=expand("<cword>")<CR><CR>
nnoremap <C-\>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
nnoremap <C-\>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
" Set Up and Down non-linewise
noremap <Up> gk
noremap <Down> gj
" Toggle Tagbar
nnoremap <silent> <F2> :TagbarToggle<CR>
" Grep search tools
nnoremap <F3> :Rgrep<CR>
" Paste toggle
set pastetoggle=<F4>
" Save & Make
nnoremap <F5> :w<CR>:make!<CR>
nnoremap <F6> :w<CR>:make! %< CC=gcc CFLAGS="-g -Wall"<CR>:!./%<<CR>
" Quickfix window
nnoremap <silent> <F7> :botright copen<CR>
nnoremap <silent> <F8> :cclose<CR>
" NERDTreeToggle
nnoremap <silent> <F9> :NERDTreeToggle<CR>
" Toggle display line number
nnoremap <silent> <F10> :set number!<CR>
" Use <space> to toggle fold
nnoremap <silent> <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
" Use xsel to access the X clipboard
if $DISPLAY != '' && executable('xsel')
nnoremap <silent> "*y :'[,']w !xsel -i -p -l /dev/null<CR>
nnoremap <silent> "*p :r!xsel -p<CR>
nnoremap <silent> "+y :'[,']w !xsel -i -b -l /dev/null<CR>
nnoremap <silent> "+p :r!xsel -b<CR>
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
filetype off
set runtimepath+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'Lokaltog/vim-powerline'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'Align'
Bundle 'autoload_cscope.vim'
Bundle 'bufexplorer.zip'
Bundle 'ctrlp.vim'
Bundle 'DrawIt'
Bundle 'echofunc.vim'
Bundle 'fcitx.vim'
Bundle 'grep.vim'
Bundle 'Indent-Guides'
Bundle 'matchit.zip'
Bundle 'snipMate'
Bundle 'SuperTab-continued.'
Bundle 'Tagbar'
Bundle 'The-NERD-Commenter'
Bundle 'The-NERD-tree'
filetype plugin indent on