-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
333 lines (282 loc) · 10.4 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
set nocp
filetype off
set rtp+=/opt/vim/bundle/vundle/
call vundle#rc("/opt/vim/bundle")
Bundle 'gmarik/vundle'
source /opt/vim/vimrc.vundle
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
syntax on
set hlsearch " search highlighting
"colorscheme elflord
colorscheme kolor
set background=dark
" auto reload vimrc when editing it
autocmd! bufwritepost .vimrc source ~/.vimrc
set nocp
set ts=4
set sw=4
set expandtab
set smarttab
set smartindent
set smartcase
set hlsearch
set magic
set hidden
set undolevels=1000
set wildignore=*.swp,*.pyc,*.pyo
set title
set noerrorbells
set mouse=a
set showcmd
set backspace=indent,eol,start
set showmatch " Cursor shows matching ) and }
set showmode " Show current mode
set wildchar=<TAB> " start wild expansion in the command line using <TAB>
set wildmenu " wild char completion menu
autocmd FileType python setlocal tabstop=8 expandtab shiftwidth=4 softtabstop=4 autoindent smarttab colorcolumn=120
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
" status line
set laststatus=2
set statusline=\ %{HasPaste()}%<%-15.25(%f%)%m%r%h\ %w\ \
set statusline+=\ \ \ [%{&ff}/%Y]
set statusline+=\ \ \ %<%20.30(%{hostname()}:%{CurDir()}%)\
set statusline+=%=%-10.(%l,%c%V%)\ %p%%/%L
" ignore these files while expanding wild chars
set wildignore+=.svn,CVS,.git
set wildignore+=*.o,*.a,*.class,*.mo,*.la,*.so,*.lo,*.la,*.obj,*.pyc
set wildignore+=*.exe,*.zip,*.jpg,*.png,*.gif,*.jpeg,.DS_Store
" folding
"set foldenable
set foldmethod=marker
set foldlevel=0
set foldcolumn=0
"---------------------------------------------------------------------------
" USEFUL SHORTCUTS
"---------------------------------------------------------------------------
" set leader to ;
let mapleader=";"
let g:mapleader=";"
" quick alias to leave vim
nmap <leader>w :x<CR>
nmap <leader>q :q!<CR>
"replace the current word in all opened buffers
map <leader>r :call Replace()<CR>
" ;/ turn off search highlighting
nmap <leader>/ :set hls!<CR>
nnoremap <silent><leader>s :nohlsearch<CR>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
" ;p toggles paste mode
nmap <leader>p :set paste!<BAR>set paste?<CR>
" open the error console
map <leader>er :bo cope<CR>
" move to next error
map <leader>] :cn<CR>
" move to the prev error
map <leader>[ :cp<CR>
" :cd. change working directory to that of the current file
cmap cd. lcd %:p:h
" Quickly resize windows use +/-
map - <C-W>-
map + <C-W>+
map > <C-W>>
map < <C-W><
" Allows all window commands in insert mode
imap <C-w> <C-o><C-w>
" Loop to switch windows
nmap <S-w> :wincmd w<CR>
" new tab
map <C-t><C-t> :tabnew .<CR>
" close tab
"map <C-t><C-w> :tabclose<CR>
"---------
"Functions
"---------
fun! CurDir()
let curdir = substitute(getcwd(), $HOME, "~", "")
return curdir
endfun
fun! HasPaste()
if &paste
return '[PASTE]'
else
return ''
endif
endfun
"---------------------------------------------------------------------------
" Tip #382: Search for <cword> and replace with input() in all open buffers
"---------------------------------------------------------------------------
fun! Replace()
let s:word = input("Replace " . expand('<cword>') . " with:")
:exe 'bufdo! %s/\<' . expand('<cword>') . '\>/' . s:word . '/ge'
:unlet! s:word
endfun
"---------------------------------------------
" Enable omni completion. (Ctrl-X Ctrl-O)
"---------------------------------------------
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType java set omnifunc=javacomplete#Complete
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
" use syntax complete if nothing else available
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
set cot-=preview "disable doc preview in omnicomplete
"---------------------------------------------
" for edit CSS
"---------------------------------------------
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" make CSS omnicompletion work for SASS and SCSS
autocmd BufNewFile,BufRead *.scss set ft=scss.css
autocmd BufNewFile,BufRead *.sass set ft=sass.css
"---------------------------------------------
" for edit HTML
"---------------------------------------------
autocmd FileType html,xhtml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
"---------------------------------------------
" file type detection
"---------------------------------------------
" highlight action script and mxml syntax
au BufNewFile,BufRead *.mxml set filetype=mxml
au BufNewFile,BufRead *.as set filetype=actionscript
au BufNewFile,BufRead *.less set filetype=less
"---------------------------------------------
" use w!! to write protected files
"---------------------------------------------
cmap w!! %!sudo tee > /dev/null %
"---------------------------------------------
" copy to system buffer
"---------------------------------------------
vnoremap <C-S-C> "+y<CR>
map <C-S-c> "+y<CR>
map <C-S-v> "+p<CR>
" Ctrl-[ jump out of the tag stack (undo Ctrl-])
"map <C-[> <ESC>:po<CR>
map <leader>g :call IncludeGuard()<CR>
fun! IncludeGuard()
let basename = substitute(bufname(""), '.*/', '', '')
let guard = '_' . substitute(toupper(basename), '\.', '_', "H") . '_'
call append(0, "#ifndef " . guard)
call append(1, "#define " . guard)
call append(line("$"), "#endif /* " . guard . " */")
endfun
"---------------------------------------------------------------------------
" COLOR SCHEME OVERRIDE
"---------------------------------------------------------------------------
hi StatusLine ctermfg=gray ctermbg=black
hi StatusLineNC ctermfg=darkblue ctermbg=gray
"---------------------------------------------------------------------------
" PLUGIN SETTINGS
"---------------------------------------------------------------------------
" --- Syntastic
nnoremap <silent> <F6> :SyntasticCheck<CR>
nnoremap <leader>sy :SyntasticCheck<CR>
let g:syntastic_auto_loc_list = 1
"let g:syntastic_auto_jump = 1
" --- neocomplcache
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 0
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 2
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default': '',
\ 'vimshell': '~/.vimshell_hist',
\ 'scheme': '~/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
"imap <C-k> <Plug>(neocomplcache_snippets_expand)
"smap <C-k> <Plug>(neocomplcache_snippets_expand)
"inoremap <expr><C-g> neocomplcache#undo_completion()
"inoremap <expr><C-l> neocomplcache#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
"fun! s:my_cr_func()
" return pumvisible() ? neocomplcache#smart_close_popup() : "\<CR>"
"endfun
"inoremap <expr><CR> neocomplcache#smart_close_popup()."\<CR>"
"inoremap <silent> <CR> <C-r>=<SID>my_cr_func()<CR>
" <TAB>: completion.
"inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
"inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
"inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
"inoremap <expr><C-y> neocomplcache#close_popup()
"inoremap <expr><C-e> neocomplcache#cancel_popup()
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
" --- vim-javascript
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
"---------------------------------------------
" using ctags
"---------------------------------------------
set tags=tags
"---------------------------------------------
" shorcut for ctags
" http://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks
"---------------------------------------------
map <C-\> :bel 8sp <CR>:exec("tag ".expand("<cword>"))<CR>
let g:BASH_GlobalTemplateFile = $HOME.'/.vim/bash-support/templates/Templates'
if exists('g:pymode_options_max_line_length')
let g:pymode_options = 1 " Set default python options
let g:pymode_warnings = 1 " Disable noisy warnings
let g:pymode_folding = 1 " Enable folding by default
let g:pymode_lint = 0 " Disable pylint
let g:pymode_rope = 0
let g:pymode_rope_autoimport = 0
let g:pymode_rope_autoimport_modules = ['os', 'os.path', 're', 'shutil', 'sys', 'datetime']
let g:pymode_rope_autoimport_import_after_complete = 0
let g:pymode_options_max_line_length = 120
" Override go-to.definition key shortcut to Ctrl-]
let g:pymode_rope_goto_definition_bind = "<C-]>"
" Override run current python file key shortcut to Ctrl-Shift-e
let g:pymode_run_bind = "<C-S-e>"
" Override view python doc key shortcut to Ctrl-Shift-d
let g:pymode_doc_bind = "<C-S-d>"
endif
"inoremap <C-w> <C-\><C-o><ESC><C-w>
"inoremap <C-w> <C-\><C-o>dB
""inoremap <C-w> <C-\><C-o>daw
"inoremap <C-w> <c-o>daw<c-w>
" Works best:
inoremap <C-w> <C-\><C-o>db
inoremap <C-x> <C-\><C-o>dB
"inoremap <expr> <C-w> wordchipper#chipWith('db')
"inoremap <expr> <C-w> wordchipper#chipWith('dB')
"inoremap <expr> <C-x> wordchipper#chipWith('db')
let g:pymode_lint_config = $HOME.'/.pylint.rc'
let g:AutoClosePreserveDotReg = 0
let g:jedi#popup_on_dot = 0
let g:ycm_key_list_select_completion = []
source /opt/vim/vimrc-init.vim