-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
188 lines (155 loc) · 5.19 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
" general
set nocp " get out of horrible vi-compatible mode
sil! call pathogen#infect()
if has('autocmd')
filetype indent plugin on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
set history=1000 " How many lines of history to remember
set cf " enable error files and error jumping
set clipboard+=unnamed " turns out I do like sharing windows clipboard
set ffs=unix,dos,mac " support all three, in this order
set viminfo+=! " make sure it can save viminfo
set isk+=_,$,@,%,#,- " none of these should be word dividers, so make them not be
set enc=utf-8 " use UTF-8 encoding
set t_Co=256 " this terminal has 256 colors
if has("gui_running")
if has("unix")
set guifont=Bitstream\ Vera\ Sans\ Mono\ 18
elseif has("win32")
set guifont=Consolas:h18:cANSI
endif
endif
" theme
set bg=dark
sil! colo diablo3
set ar aw
if isdirectory(expand('~/.cache/vim'))
if &dir =~# '^\.,'
set dir^=~/.cache/vim/swap//
endif
if &bdir =~# '^\.,'
set bk
set bdir^=~/.cache/vim/backup//
endif
if exists('+undofile') && exists('+undodir') && &undodir =~# '^\.\%(,\|$\)'
set undofile
set undodir^=~/.cache/vim/undo//
set ul=1000
endif
if exists('+quickfix')
set mef^=~/.cache/vim/make.log
endif
if has("spell")
set spl=en_us
set spf^=~/.cache/vim/custom_words.en_us.utf-8.add
set tsr+=~/.cache/vim/mthesaur.txt
endif
endif
if exists('+autochdir')
set autochdir
endif
" wild menu
set wmnu wim=list:longest,full wig=CVS,.git,*.o,*.class,*.la,*.so,*.obj,*.swp
set lsp=0 " space it out a little more (easier to read)
set ru " Always show current positions along the bottom
set cmdheight=2 " the command bar is 2 high
set nu " turn on line numbers
set lz " do not redraw while running macros (much faster) (LazyRedraw)
set hid " you can change buffer without saving
set backspace=2 " make backspace work normal
set whichwrap+=<,>,h,l " backspace and cursor keys wrap to
set shortmess=atI " shortens messages to avoid 'press a key' prompt
set report=0 " tell us when anything is changed via :...
set ss=1 " sidescroll behavior for fast terminals (stops the jumping when off screen with nowrap)
set noek ttimeout tm=1000 ttm=100
if has('mouse')
set mouse=a " use mouse everywhere
endif
" make the splitters between windows be blank
"set fillchars=vert:\ ,stl:\ ,stlnc:\
" visual cues
set sm " show matching brackets
set novb noeb " don't blink & no noises
"set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2 " always show the status line
set statusline=%f\ %{fugitive#statusline()}\ [line\ %l\/%L]
hi StatusLine ctermfg=Black ctermbg=White
au InsertEnter * hi StatusLine ctermbg=White ctermfg=DarkRed
au InsertLeave * hi StatusLine ctermbg=White ctermfg=Black
hi ExtraWhitespace ctermbg=red guibg=red
mat ExtraWhitespace /\s\+$/
au BufWinEnter * mat ExtraWhitespace /\s\+$/
au InsertEnter * mat ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * mat ExtraWhitespace /\s\+$/
au BufWinLeave * call clearmatches()
" what to show when I set list
set listchars=tab:»·,trail:·,extends:>,precedes:<,eol:¬
" text formatting/layout
set fo=crqn " format options
set cot=menuone,longest,preview " complete options
set nowrap " do not wrap lines
let c_no_curly_error=1 " fixes the C++0x issue with braces and lambdas
set et sta ts=2 sts=2 sw=2 " tab
set ai si cin ci " indenting
set hls is ic scs " search
set gd
" folding
if exists("&fen")
set fen fdm=syntax fdl=99 fdls=99
endif
" clang_complete
"let g:clang_exec="${HOME}/local/bin/clang"
"let g:clang_library_path="${HOME}/local/lib/libclang.so"
" mappings
" toggles
nnoremap <leader>l :setl list!<CR>
nnoremap <leader>w :setl wrap!<CR>
nnoremap <leader>h :nohls<CR>
nnoremap <leader>e :Vex<CR>
nnoremap <leader>v :e $MYVIMRC<CR>
nnoremap <leader>c :setl cuc! cul!<CR>
nnoremap <leader>s :setl spell! spelllang=en_us<CR>
set pt=<leader>p
" Map Q -> gq (better ex mode)
nnoremap Q gq
vnoremap Q gqap
nnoremap Y y$
" Remappings
nnoremap <Space> <PageDown>
nnoremap <S-Space> <PageUp>
vnoremap <Leader>b :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
fu! CompileAndRunCppFile()
"exec "!g++ -std=gnu++0x % -o %< && %<"
exec "!/usr/local/gcc-4.8.1/bin/g++ -std=gnu++0x % -o %< && %<"
endf
nnoremap <leader>m :call CompileAndRunCppFile()<CR>
set tw=80
if exists("&cc")
set cc=0
fu! ToggleLongLines()
"let limit = (&tw ? &tw : 80)
if &cc=='0'
set cc=+1
hi OverLength ctermfg=red gui=undercurl guisp=darkred
match OverLength /\%81v.*/
else
set cc=0
hi clear OverLength
endif
endf
nnoremap <leader>f :call ToggleLongLines()<CR>
endif
" autocommands
if has('autocmd')
au BufEnter * :syntax sync fromstart " ensure full syntax highlighting
au BufWritePost .vimrc so %
au FileType text setlocal tw=80
endif
if executable("ag")
set grepprg=ag\ --nogroup\ --nocolor
endif
" abbrevs
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>