/
vimrc.after
58 lines (47 loc) · 1.83 KB
/
vimrc.after
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
map <leader>bo :BufOnly<CR>
" taken from: http://blog.kamil.dworakowski.name/2009/09/unobtrusive-highlighting-of-trailing.html
highlight ExtraWhitespace ctermbg=red guibg=red
au ColorScheme * highlight ExtraWhitespace guibg=red
au BufEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhiteSpace /\s\+$/
" taken from: http://stackoverflow.com/questions/356126/how-can-you-automatically-remove-trailing-whitespace-in-vim/1618401#1618401
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" auto-strip trailing white space for ruby files
"autocmd BufWritePre *.rb :call <SID>StripTrailingWhitespaces()
" command to strip white space from any file
nnoremap <leader>s :call <SID>StripTrailingWhitespaces()<cr>
" Ignore for CtrlP
set wildignore+=*/vendor/bundle/*,*/tmp/*
" add Ack options - mainly want the ignore directory command.
" taken from https://github.com/AndrewRadev/ack.vim
function! s:AckOption(bang, ...)
for option in a:000
let remove = (a:bang == '!')
let base_option = substitute(option, '^no', '', '')
let pattern = '\v\s+--(no)?\V'.base_option
if remove
let replacement = ''
else
let replacement = ' --'.option
endif
if g:ackprg =~ pattern
let g:ackprg = substitute(g:ackprg, pattern, replacement, '')
else
let g:ackprg .= ' --'.option
endif
endfor
endfunction
function! s:AckIgnore(bang, ...)
for directory in a:000
silent call s:AckOption(a:bang, 'ignore-dir="' . directory . '"')
endfor
endfunction
command! -bang -nargs=* -complete=file AckIgnore call s:AckIgnore('<bang>', <f-args>)
" Ignore vendor directoy for Ack searches
AckIgnore! vendor