-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
324 lines (269 loc) · 7.41 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
scriptencoding utf-8
let no_flake8_maps=1
execute pathogen#infect()
set nocompatible
set mouse=a
set tabstop=2
set softtabstop=2
set smarttab
set shiftwidth=2
set expandtab
set list listchars=tab:>-,trail:·
set viminfo='1000,f1,:1000,/1000
set backspace=indent,eol,start
set showcmd
set showmatch
set incsearch
set infercase
set hlsearch
set showfulltag
set lazyredraw
set noerrorbells
set visualbell t_vb=
autocmd GUIEnter * set visualbell t_vb=
set scrolloff=3
set sidescrolloff=2
set nowrap
set whichwrap+=<,>,[,]
set wildmenu
set wildmode=list:longest
set wildignore=*.o,*~
set hidden
set winminheight=1
set textwidth=80
syntax on
set switchbuf=useopen,usetab,newtab
set undodir=~/.vim/undo
set undofile
" backupcopy=auto breaks parcel
set backupcopy=yes
set secure
set exrc
" splits
set splitbelow
set splitright
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" fix whitespace
"command Fixws :retab<CR>:%s/\s\+$//<CR>
" Try to load a nice colourscheme
fun! LoadColourScheme(schemes)
let l:schemes = a:schemes . ":"
while l:schemes != ""
let l:scheme = strpart(l:schemes, 0, stridx(l:schemes, ":"))
let l:schemes = strpart(l:schemes, stridx(l:schemes, ":") + 1)
try
exec "colorscheme" l:scheme
break
catch
endtry
endwhile
endfun
if has('gui')
call LoadColourScheme("inkpot:torte:night:rainbow_night:darkblue:elflord")
else
if &t_Co == 88 || &t_Co == 256
call LoadColourScheme("inkpot:torte:darkblue:elflord")
else
call LoadColourScheme("torte:darkblue:elflord")
endif
endif
" Do clever indent things. Don't make a # force column zero.
set autoindent
set smartindent
inoremap # X<BS>#
" Enable folds...
set foldmethod=indent
" ...but open all folds
set nofoldenable
" Syntax when printing
set popt+=syntax:y
" extra tags
source ~/.vim/tags/tags.vim
" Enable filetype settings
filetype on
filetype plugin on
filetype indent on
set modeline
" Nice statusbar
set laststatus=2
set statusline=
set statusline+=%n/ " buffer number
set statusline+=%{len(filter(range(1,bufnr('$')),'buflisted(v:val)'))}\ "number of ubbfers
set statusline+=%f\ " file name
set statusline+=%h%m%r%w " flags
set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&encoding}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%= " right align
set statusline+=0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
" If possible, try to use a narrow number column.
try
setlocal numberwidth=3
catch
endtry
set fillchars=fold:-
set dictionary=/usr/share/dict/words
" draw numbers in wide windows
autocmd BufEnter * :call <SID>WindowWidth()
" Turn off search highlight when idle
autocmd CursorHold * nohls | redraw
" Always do a full syntax refresh
autocmd BufEnter * syntax sync fromstart
" For help files, move them to the top window and make <Return>
" behave like <C-]> (jump to tag)
autocmd FileType help :call <SID>WindowToTop()
autocmd FileType help nmap <buffer> <Return> <C-]>
" If we're in a wide window, enable line numbers.
fun! <SID>WindowWidth()
if bufname("%") != "-MiniBufExplorer-"
if winwidth(0) > 90
setlocal foldcolumn=1
setlocal number
else
setlocal nonumber
setlocal foldcolumn=0
endif
endif
endfun
" Force active window to the top of the screen without losing its
" size.
fun! <SID>WindowToTop()
let l:h=winheight(0)
wincmd K
execute "resize" l:h
endfun
" Force active window to the bottom of the screen without losing its
" size.
fun! <SID>WindowToBottom()
let l:h=winheight(0)
wincmd J
execute "resize" l:h
endfun
command -bang -nargs=? QFix call QFixToggle(<bang>0)
function! QFixToggle(forced)
if exists("g:qfix_win") && a:forced == 0
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
endif
endfunction
nmap <silent> <S-Right> :bnext<CR>
" Make <space> in normal mode go down a page rather than left a
" character
noremap <space> <C-f>
" Map key to toggle opt
function MapToggle(key, opt)
let cmd = ':set '.a:opt.'! \| set '.a:opt."?\<CR>"
exec 'nnoremap '.a:key.' '.cmd
exec 'inoremap '.a:key." \<C-O>".cmd
endfunction
command -nargs=+ MapToggle call MapToggle(<f-args>)
" Commonly used commands
MapToggle <F1> paste
nmap <F2> :AT<CR>
MapToggle <F3> hlsearch
map <F4> :!ctags -R --c++-kinds=+p --fields=+iaS --extras=+q . && cscope -Rb<CR>
map <F6> :bprev<CR>
map <F7> :bnext<CR>
nmap <F8> :make<CR>
nnoremap <silent> <F9> :Tlist<CR>
map <silent> <F10> :QFix<CR>
map <silent> <F11> :redo<CR>
nmap <F12> :bd<CR>
map <S-PageUp> :cprev<CR>
map <S-PageDown> :cnext<CR>
" Insert a single char
noremap <Leader>i i<Space><Esc>r
" Split the line
nmap <Leader>n \i<CR>
" Pull the following line to the cursor position
noremap <Leader>J :s/\%#\(.*\)\n\(.*\)/\2\1<CR>
" In normal mode, jj escapes
inoremap jj <Esc>
" Select everything
noremap <Leader>gg ggVG
" Reformat everything
noremap <Leader>gq gggqG
" Reformat paragraph
noremap <Leader>gp gqap
" Clear lines
noremap <Leader>clr :s/^.*$//<CR>:nohls<CR>
" Delete blank lines
noremap <Leader>dbl :g/^$/d<CR>:nohls<CR>
" Enclose each selected line with markers
noremap <Leader>enc :<C-w>execute
\ substitute(":'<,'>s/^.*/#&#/ \| :nohls", "#", input(">"), "g")<CR>
" save as root
cmap w!! w !sudo tee '%' >/dev/null
" set up some more useful digraphs
digraph ., 8230 " ellipsis (…)
" GNU format changelog entry
fun! MakeChangeLogEntry()
norm gg
/^\d
norm 2O
norm k
call setline(line("."), strftime("%Y-%m-%d") .
\ " Christoph Gysin <[email protected]>")
norm 2o
call setline(line("."), "\t* ")
norm $
endfun
noremap ,cl :call MakeChangeLogEntry()<CR>
" plugin / script / app settings
" Vim specific options
let g:vimsyntax_noerror=1
" Settings for taglist.vim
let Tlist_Use_Right_Window=1
let Tlist_Auto_Open=0
let Tlist_Enable_Fold_Column=0
let Tlist_Compact_Format=1
let Tlist_WinWidth=28
let Tlist_Exit_OnlyWindow=1
let Tlist_File_Fold_Auto_Close = 1
"autocmd FileType c,cpp :Tlist
" Settings for a.vim
let g:alternateExtensions_h = "c,cc,cpp"
let g:alternateExtensions_hh = "cc,cpp"
let g:alternateExtensions_cc = "h,hh,hpp"
let g:alternateExtensions_cpp = "h,hh,hpp"
let g:alternateSearchPath = '../source,../src,../../src,../include,../inc,../../inc'
let g:alternateNoDefaultAlternate = 1
" Settings minibufexpl.vim
let g:miniBufExplWinFixHeight = 1
let g:miniBufExplForceSyntaxEnable = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" Settings for showmarks.vim
if has("gui_running")
let g:showmarks_enable=1
else
let g:showmarks_enable=0
let loaded_showmarks=1
endif
" Settings for explorer.vim
let g:explHideFiles='^\.'
" Settings for netrw
let g:netrw_list_hide='^\.,\~$'
" Settings for :TOhtml
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
" syntastic
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11'
" final commands
" turn off any existing search
autocmd VimEnter * nohls
if filereadable(glob('~/.vimrc.local'))
source ~/.vimrc.local
endif
" vim: set shiftwidth=4 softtabstop=4 expandtab tw=72