summaryrefslogtreecommitdiff
path: root/.vimrc
blob: c43cc82438f9f63eaab4e98607d22c0728f75278 (plain)
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
" {{{ General settings
set nocompatible	" Forget about (N)VI
set noerrorbells	" No annoying bells
set vb t_vb=
set hidden		" allow buffer switching without saving

" Don't highlight search results
" set nohlsearch

" Type-ahead find
set incsearch

" Indent of 8, but no spaces
set shiftwidth=8
set tabstop=8

" Allow backspacing over indentation, end-of-line and start-of-line
set backspace=2

" smart autoindenting
set smartindent

" Paste toggle (a.k.a set paste/set nopaste)
set pastetoggle=<F11>

" Enable folding by fold markers
set foldmethod=marker

" Wrap line longer than the display
"set wrap
" Textwidth of 80 (Standard terminal)
set tw=80

" Number of undo operations to store
set undolevels=50

set laststatus=2	" Always show the statusline
set ruler		" Display ruler with cursor positions

"set cursorline		" Highlight the cursor line and column

" Buffer, filename, line, total lines, column, ASCII value
"set statusline=[%n]\ %f\ %m\ %l/%L,%c\ ASCII:\ %3b
"set statusline+=[%{strlen(&fenc)?&fenc:'none'}, " file encoding
"set statusline+=%{&ff}] 			" file format

" maximum number of tabs to open
set tabpagemax=20

set showmode
set modeline
set backupcopy=auto,breakhardlink

filetype on		" Enable filetype detection
filetype indent on	" Enable filetype specific indenting
filetype plugin on	" Enable filetype specific plugins

au FileType c set cindent

let g:git_diff_spawn_mode=2

" }}}
" {{{ Colors and fonts

set background=dark
let g:solarized_termtrans=1
colorscheme solarized

" Syntax highlighting
if &t_Co > 2 || has("gui_running")
	syntax on
endif

" Highlight trailing whitespaces
let c_space_errors=1
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/

" }}}
" {{{ Completion
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
" }}}
" {{{ Mappings
let mapleader=","

" Line numbering toggle
nmap <C-x>n :set invnumber<CR>
"highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE

map <C-x>s ^iSigned-off-by: <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><ESC>^
map! <C-x>s Signed-off-by: <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><CR>

map <C-x>a ^iAcked-by: <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><ESC>^
map! <C-x>a Acked-by: <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><CR>

map <C-x>r ^iReviewed-by: <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><ESC>^
map! <C-x>r Reviewed-by: <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><CR>

map <C-x>y ^iCopyright (C) <C-R>=strftime("%Y")<CR> <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><CR><ESC>^
map! <C-x>y Copyright (C) <C-R>=strftime("%Y")<CR> <C-r>=$GIT_AUTHOR_NAME<CR> <<C-r>=$GIT_AUTHOR_EMAIL<CR>><CR>

map <C-x>c i<C-R>=strftime("%F %R")<CR> Tobias Klauser <tklauser@distanz.ch><CR><TAB>* <ESC>
map! <C-x>c <C-R>=strftime("%F %R")<CR> Tobias Klauser <tklauser@distanz.ch><CR><TAB>* 

map <C-x>f ^iFrom: Tobias Klauser <tklauser@distanz.ch><CR><ESC>^
map! <C-x>f From: Tobias Klauser <tklauser@distanz.ch><CR>

map <F9> :let &background = ( &background == "dark" ? "light" : "dark" )<CR>
map <F10> <ESC>:! make<CR>

map! <C-x><SPACE> &nbsp;

map <C-p> :Files<CR>
map <C-f> :NERDTreeFind<CR>

" Remove all trailing whitespaces in file
map <leader>w :%s/\s\+$//<CR>^
map! <leader>w <ESC>:%s/\s\+$//<CR>

" Remove Mac/DOS line-breaks
map <leader>lb :%s/
//<CR>^
map! <leader>lb <ESC>:%s/
//<CR>

" Navigate non-breaking lines more easily
" from http://zinformatik.de/tipps-tricks/vim-tipps/einige-tipps-und-tricks-fur-vim/
noremap <C-J> gj
noremap <C-K> gk

" Thanks mikap! http://michael-prokop.at/computer/config/.vimrc
map !f !perl -MText::Autoformat -e'autoformat'
map ;0 <ESC>:'<,'>!boxes
map ;1 <ESC>:'<,'>!boxes -d boxquote
map ;2 <ESC>:'<,'>!boxes -d peek -a c -s 40x5
map ;3 <ESC>:'<,'>!boxes -d c-cmt
map ;4 <ESC>:'<,'>!boxes -d dog -a c
map ;5 <ESC>:'<,'>!boxes -d simple -a jr
map ;6 <ESC>:'<,'>!boxes -d headline

map <Leader>hon :%!xxd<CR>
map <Leader>hof :%!xxd -r<CR>

" delete the text until start of the mail signature with ,k
map <Leader>k d/^-- $<CR>

" line numbering
map <Leader>ln :%s/^/\=line('.')/<CR><ESC>

" add a comment
map <Leader>mkc i/*  */<Left><Left><Left>

" greet to the person you write a mail
map <Leader>a  G/^\* /e+1<CR>ye1G}oHallo <c-r>",<cr><ESC>

" }}}
" {{{ Abbrevations
ab mfg Mit freundlichen Grüssen
" }}}
" {{{ VIM LaTeX
let g:Imap_UsePlaceHolders = 0
" }}}
" {{{ VIM VHDL
" for taglist
"let loaded_taglist = 'no' " disable for now
let g:tlist_vhdl_settings = 'vhdl;d:package declarations;b:package bodies;e:entities;a:architecture specifications;t:type declarations;p:processes;f:functions;m:port maps;r:procedures'
nnoremap <silent> <F8> :TlistToggle<CR>
" }}}
" {{{ Automatically create C header file skeletons
augroup c
	autocmd BufNewFile *.h :0r! mkheader.py -s <afile>
augroup END
" }}}
" {{{ Always use tabs in Makefiles
autocmd BufEnter ?akefile* set noet ts=8 sw=8 nocindent
" }}}
" {{{ pathogen plugin
execute pathogen#infect()
" }}}
" {{{ settings for bundles installed by pathogen

" syntastic
let g:syntastic_check_on_wq = 0
let g:syntastic_auto_loc_list = 1
let g:syntastic_enable_balloons = 0
let g:syntastic_c_checkers = [ ]
let g:syntastic_cpp_checkers = [ 'cpplint' ]
let g:syntastic_cpp_cpplint_args = '--verbose=0'
let g:syntastic_mode_map = { "mode": "passive", "active_filetypes": [], "passive_filetypes": [] }
map <Leader>li :SyntasticCheck<CR>

" NERDTree
autocmd vimenter * if !argc() | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
map <Leader>nt :NERDTreeToggle<CR>

" }}}
" {{{ localvimrc plugin
" disable sandbox to allow autocmd
let g:localvimrc_sandbox=0
" don't ask before loading
let g:localvimrc_ask=0
" }}}