-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot.vimrc
More file actions
375 lines (313 loc) · 8.31 KB
/
Copy pathdot.vimrc
File metadata and controls
375 lines (313 loc) · 8.31 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
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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" VIM settings from Changshu LIU (changshuliu[at]gmail[dot]com)
" Last updated on: 07-30-2013
"
" some useful links:
" = vim option reference
" - http://vimdoc.sourceforge.net/htmldoc/options.html
" - :h options
" = vimrc example
" - http://www.slackorama.com/projects/vim/vimrc.txt
" - http://amix.dk/vim/vimrc.html
" = vimrc repo
" - http://dotfiles.org/.vimrc
"
" NOTE:
" - run "set rtp" to get run time path, where plugins can be stored
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Functions
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" detect current platform
" :h feature_list to get more info
function! GetCurrentPlatform()
if has("win64") || has("win32") || has("win16")
return "windows"
elseif has("maxunix")
return "mac"
else if has("unix")
let s:uname = substitute(system("uname"), "\n", "", "");
if s:uname == "Darwin"
return "mac"
else
return "unix"
endif
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" uses vim settings rather than vi settings
set nocompatible
" turn off error sounds
set noerrorbells
set novisualbell
" verboseness switch to see everything vim is doing
set verbose=0
" mouse settings
set selectmode=mouse
set mouse=a
set ttyfast
"set ttymouse=xterm2
" set utf8 as standard encoding
set encoding=utf8
" set End-Of-Line format
set fileformats=unix,mac,dos
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Visual
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" display unprintable char
set listchars=tab:>-
set list
" show wild menu
set wildmenu
set wildignore=*.o,*~,*.pyc
" use dark backgroud
set background=dark
" show line number
set number
" line width
if has('gui_running')
set columns=100
endif
" show colored column
set colorcolumn=80
" command window height
set cmdheight=2
" command history length
set history=10
" always display status line
set laststatus=2
" show status line in each vim window in given format
set statusline=[%02n]\ %f\ %(\[%M%R%H]%)%=\ %4l,%02c%2V\ %P%*
" always display ruler
set ruler
" gui display font
if has('gui_running')
"set guifont=Bitstream\ Vera\ Sans\ Mono\ 9
endif
" always have some lines of text when scrolling
set scrolloff=5
" gui config - no menu, no toolbar, no scrollbars
set guioptions-=r
set guioptions-=l
"set guioptions-=m
set guioptions-=T
" stop blinking cursor
set guicursor=a:blinkon0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Tab & Indention
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" replace tab with space char
set expandtab
" use tab in a smart way
set smarttab
" number of space when input tab
set tabstop=2
" number of space when doing auto indention
set shiftwidth=2
" copy indent from current line when newing line
set autoindent
" turn on smart indention
set smartindent
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Editing
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" auto load file when it's modified outside
set autoread
" set CWD to current file dir
set autochdir
" no backup files
set nobackup
set nowritebackup
" backup files
"set backupdir=~/tmp
" swap files$
"set directory=~/tmp
" paste
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
"set paste
"set nopaste
" delete to the left in insert mode with backspace
set backspace=indent,eol,start
" chars to wrap lines
set whichwrap+=<,>,h,l
" break at words
set linebreak
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Search
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ignore case in search
set ic
" incremental search
set incsearch
" highlight search results
set hlsearch
" ignore case when lowercase
set smartcase
" default to replace all occurence in a line
set gdefault
" Visual mode pressing * or # searches for the current selection
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Keybinding
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" enable extra key combination
let mapleader=","
let g:mapleader=","
" better window switching
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" keys for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" Opens a new tab with the current buffer's path
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
if has("mac") || has("macunix")
nmap <D-j> <M-j>
nmap <D-k> <M-k>
vmap <D-j> <M-j>
vmap <D-k> <M-k>
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
filetype off
"
" vundle
"
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle "gmarik/vundle"
"
" git
"
Bundle "tpope/vim-fugitive"
"
" colorschemes
" https://github.com/flazz/vim-colorschemes
" https://code.google.com/p/vimcolorschemetest/
"
Bundle "flazz/vim-colorschemes"
if has("gui_running")
colorscheme putty
endif
"
" plugin - ctags
" http://www.vim.org/scripts/script.php?script_id=610
" It needs: http://ctags.sourceforge.net/
"
"Bundle "ctags.vim"
"let g:ctags_path=/usr/bin/ctags
"let g:ctags_title=1
"let g:ctags_statusline=1
"let g:ctags_regenerate=0
"let generate_tags=1
"nmap <C-F12>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
"
" plugin - Cscope
" http://cscope.sourceforge.net/
" http://cscope.sourceforge.net/cscope_maps.vim
" usage: cscope -Rbq -f path-to-file.out
"
"Bundle "cscope.vim"
"
" plugin - TagBar
" http://github.com/majutsushi/tagbar
" NOTE: it won't work with GNU ctags
" usage: N/A
"
Bundle "majutsushi/tagbar"
nmap <F8> :TagbarToggle<CR>
"
" plugin - NerdTree
" http://github.com/scrooloose/nerdtree
" usage: NERDTreeToggle
"
Bundle "scrooloose/nerdtree"
"autocmd vimenter * NERDTree
autocmd bufenter *
\ if (winnr("$") == 1
\ && exists("b:NERDTreeType")
\ && b:NERDTreeType == "primary")
\ | q |
\ endif
"
" plugin - BufExplorer
" http://www.vim.org/scripts/script.php?script_id=42
" usage: \be, \bs, \bv
"
Bundle "bufexplorer.zip"
"
" plugin - WinManager
"
"Bundle "WinManager"
"let g:winManagerWindowLayout='NERDTree|BufferExplorer'
"let g:winManagerWidth = 30
"nmap <C-w><C-b> :BottomExplorerWindow<cr> "
"nmap <C-w><C-b> :BottomExplorerWindow<cr> "
"
" plugin - genutils
"
Bundle "genutils"
"
" plugin - lookupfile
"
Bundle "lookupfile"
"
" plugin - Alternate: a.vim
"
Bundle "csliu/a.vim"
nnoremap <silent> <F12> :A<CR>
"
" plugin - c.vim
"
Bundle "c.vim"
let g:C_BraceOnNewLine="no"
let g:C_AuthorName="Changshu Liu"
let g:C_TypeOfH = "cpp"
"
" plugin - cpp.vim
"
Bundle "cpp.vim"
"
" plugin - C++ omni-completion
"
Bundle "OmniCppComplete"
filetype plugin on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> Java
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Java
let java_highlight_all=1
let java_highlight_debug=1
let java_ignore_javadoc=1
let java_highlight_functions=1
let java_mark_braces_in_parens_as_errors=1
autocmd FileType java : set foldmethod=syntax
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"=> C/Cpp
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"autocmd FileType c,cpp : set foldmethod=syntax
syntax on