-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
364 lines (302 loc) · 8.91 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
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
set nocompatible
" General Settings {{{
filetype indent plugin on
syntax on
set autoread
set backspace=indent,eol,start
set breakindent
set complete=.,w,b,u,t
set completeopt=menuone
set cursorline
set diffopt+=iwhite
set encoding=utf-8
set fillchars=""
set foldenable
set foldmethod=marker
set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
set formatoptions=cjrq
set hidden
set history=1000
set ignorecase
set incsearch
set laststatus=1
set lazyredraw
set list
set listchars=tab:→\ ,space:·,trail:·,nbsp:•,precedes:←,extends:→,eol:¶ "eol:¬
set mouse=a
set mousehide
set hlsearch
set nomodeline
set nostartofline
set number
set numberwidth=5
set relativenumber
set ruler
set scrolloff=5
set shellslash
set showcmd
set showmode
set smartcase
set spelllang=de,en
set synmaxcol=2048
set textwidth=72
set virtualedit=block
set visualbell t_vb=
set wildignore=*.o,*.class,*.toc,*.aux
set wildmenu
" Indentation
set autoindent
set expandtab
set shiftround
set shiftwidth=4
set smartindent
set softtabstop=4
set tabstop=8
let &errorformat = "%f:%l:%c: %t%*[^:]:%m,%f:%l: %t%*[^:]:%m," . &errorformat
let g:load_doxygen_syntax = 1
let g:tex_flavor = 'latex'
let mapleader = ','
" Only use swap file if dedicated directory is available
if isdirectory(expand('~/.vimtmp'))
set directory=~/.vimtmp
elseif isdirectory(expand('~/_vimtmp'))
set directory=~/_vimtmp
else
set directory=
set noswapfile
endif
if version >= 703
set conceallevel=0
let g:tex_conceal="adgm"
endif
" }}}
" Autocommands {{{
augroup VIMRC
autocmd!
autocmd BufEnter * :silent! lcd %:p:h " auto change directory
autocmd BufRead,BufNewFile *.tex,*.txt,*.mkd setlocal spell
autocmd BufRead,BufNewFile *.des set syntax=levdes
autocmd GuiEnter * set visualbell t_vb=
autocmd colorscheme * highlight clear CursorLine
augroup END
" }}}
" PlugIn Settings {{{
" GTAGS-CScope
let g:GtagsCscope_Absolute_Path = 1
let g:GtagsCscope_Auto_Load = 0
let g:GtagsCscope_Auto_Map = 0
let g:GtagsCscope_Auto_Update_Gtags = 1
let g:GtagsCscope_Quiet = 1
" Display CScope output in quickfix window.
set cscopequickfix=s-,c-,d-,i-,t-,e-
" Use CScope for default tag lookup.
set cscopetag
" CtrlP
let g:ctrlp_map = '<c-e>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 1
" Lightline
let g:lightline = { 'colorscheme' : 'landscape' }
"let g:lightline = { 'colorscheme' : 'solarized' }
" Easy-Align
if !exists('g:easy_align_delimiters')
let g:easy_align_delimiters = {}
endif
let g:easy_align_delimiters['d'] = {
\ 'pattern': ' \ze\S\+\s*[;=]',
\ 'left_margin': 0, 'right_margin': 0
\ }
" Supertab (invoke with ctrl-space)
let g:SuperTabMappingForward = '<c-space>'
let g:SuperTabMappingBackward = '<s-c-space>'
" }}}
" (G)UI Settings {{{
" Gruvbox
let g:gruvbox_contrast_dark = "hard"
let g:gruvbox_contrast_light = "hard"
" Jellybeans
let g:jellybeans_use_gui_italics = 0
let g:jellybeans_overrides = {
\ 'SpecialKey': { 'guibg': '' },
\ 'NonText': { 'guifg': '444444' },
\}
if has("gui_running")
set guicursor=n:blinkon0
set guioptions=cem
set showtabline=1
if has("gui_win32")
set guifont=Consolas:h10
else
set guifont="Deja Vu Sans Mono 10"
endif
colorscheme Notepad++
" toggle between dark and light colorschemes
"let g:wincmd_use_legacy_colors = 1
"let g:thorstel_lightcolor = "Notepad++"
"let g:thorstel_darkcolor = "wincmd"
"let g:thorstel_darkbg = 0
"set background=light
"execute "colorscheme " . g:thorstel_lightcolor
"nnoremap <silent> <F2> :call <SID>ToggleColorScheme()<CR>
map <A-1> 1gt
map <A-2> 2gt
map <A-3> 3gt
map <A-4> 4gt
map <A-5> 5gt
map <A-6> 6gt
map <A-7> 7gt
map <A-8> 8gt
map <A-9> 9gt
map <A-0> gt
else
colo default
endif
" }}}
" Custom Commands / Functions {{{
" Compare current buffer with its unchanged state
command! DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis | wincmd p | diffthis
" Close all buffers
command! -bang Bdall bufdo bd<bang>
" Set the arglist to the filenames currently referenced in the quickfix list
command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()
function! QuickfixFilenames()
" Building a hash ensures we get each buffer only once
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
" Delete all trailings in the current buffer
command! WhiteSpaceCleanUp call <SID>DeleteTrailings()
function! <SID>DeleteTrailings()
let _s=@/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=_s
call cursor(l, c)
endfunction
" toggle between a light and a dark colorscheme
function! <SID>ToggleColorScheme()
if (g:thorstel_darkbg == 1)
set bg=light
execute "colorscheme " . g:thorstel_lightcolor
let g:thorstel_darkbg = 0
else
set bg=dark
execute "colorscheme " . g:thorstel_darkcolor
let g:thorstel_darkbg = 1
endif
endfunction
" function for switching between relative and absolute line numbers
function! <SID>SwitchLineNumbers()
if (&relativenumber == 1)
set number
set norelativenumber
else
set relativenumber
endif
endfunction
" Command for copying to the system clipboard in normal mode.
command! CopyToClipboard call <SID>CopyToClipboard()
function! <SID>CopyToClipboard()
let l = line(".")
let c = col(".")
if mode() == 'n'
normal! "+yiW
echo "Copied \"" . getreg('+') . "\" to clipboard!"
endif
call cursor(l, c)
endfunction
" }}}
" Mappings {{{
" place cursor between braces / quotes
inoremap () ()<Left>
inoremap [] []<Left>
inoremap {} {}<Left>
inoremap "" ""<Left>
inoremap '' ''<Left>
" curly brace completion
inoremap <silent> {<CR> <Esc>o{<CR>}<Esc>O
" emacs-style insert mode navigation
inoremap <C-f> <Right>
inoremap <C-b> <Left>
inoremap <C-e> <End>
inoremap <C-a> <Home>
" scroll with space
noremap <space> <C-d>
noremap <S-space> <C-u>
" Make ctrl-Backspace delete the previous word (console and gVim)
inoremap <C-h> <C-w>
inoremap <C-BS> <C-w>
" Invoke Easy-Align with tab
nmap <tab> <Plug>(EasyAlign)
xmap <tab> <Plug>(EasyAlign)
" always open file under cursor - even if it does not exist
map <silent> gf :e <cfile><CR>
" Go to the next/previous entry in the quickfix window
nnoremap <silent> <C-j> :cn<CR>
nnoremap <silent> <C-k> :cp<CR>
" Toggle settings
noremap <silent> <leader>h :nohlsearch<CR>
noremap <silent> <leader>s :set spell! <CR>
noremap <silent> <leader>w :set wrap!<CR>
" shortcut for editing the vimrc file
noremap <silent> <leader>v :e $MYVIMRC<CR>
" switch between current and alternate buffer
noremap <silent> <leader>a :b#<CR>
" close the current buffer
noremap <silent> <leader>d :bd<CR>
" switch between absolute and relative line numbers (only vim 7.3 and after)
if version >= 703
nnoremap <silent> <leader>l :call <SID>SwitchLineNumbers()<CR>
else
nnoremap <silent> <leader>l :set number!<CR>
endif
" format text with Q instead of gq
map <silent> Q gq
" spilt line at current position - opposite of J
nnoremap K i<CR><ESC>k$
" Y should copy from the current position to the end of line
nnoremap <silent> Y y$
" Use ctrl-c to copy to the system clipboard. In visual mode the current
" selection is copied. In normal mode, copy the whitespace-delimited
" word under the cursor.
vnoremap <silent> <C-c> "+y
nnoremap <silent> <C-c> :CopyToClipboard<CR>
" Paste from system clipboard with ctrl-v
vnoremap <silent> <C-v> "+p
nnoremap <silent> <C-v> o<Esc>:set paste<CR>"+p:set nopaste<CR>
inoremap <silent> <C-r><C-v> <C-r>+
" Invoke CtrlP
noremap <silent> <leader>b :CtrlPBuffer<CR>
noremap <silent> <leader>e :CtrlP<CR>
noremap <silent> <leader>t :CtrlPBufTag<CR>
noremap <silent> <leader>q :CtrlPQuickfix<CR>
" Use Ctrl-\ for the CScope reference lookup.
nnoremap <C-\> :cs find c <C-R>=expand("<cword>")<CR><CR>
" Invoke Cscope symbol lookup for the current cursor position
noremap gs :cs find s <C-R>=expand("<cword>")<CR><CR>
" Mirror the insert Time/Date of Notepad
nnoremap <F5> o<C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR><Esc>
inoremap <F5> <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
cnoremap <F5> <C-R>=strftime("%Y%m%d%H%M%S")<CR>
" For more consistency when tabbing back and forth.
nmap <F3> n
nmap <S-F3> N
" Set the search pattern to the word under the cursor and enable hlsearch.
nnoremap <silent> <C-h> :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
inoremap <silent> <C-h> <C-O>:let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR><C-O>:set hls<CR>
" adjust very frequent mistakes
iab esle else
iab flase false
iab ture true
iab itme item
iab enld endl
" }}}
" local Vim Settings
if filereadable(expand('~/.vimrc.local'))
source ~/.vimrc.local
endif
" vim: fdm=marker