summaryrefslogtreecommitdiff
path: root/.config/vim/vimrc
blob: 0270fc917a66c66c36e61f491c1c60161e8fec54 (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
"if &columns < 100
"	set columns=100
"end
"if &lines < 35
"	set lines=35
"end

set dir=/home/ben/.cache/vim/swp/
set runtimepath=$HOME/.config/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
runtime bundle/vim-pathogen/autoload/pathogen.vim

"let g:EditorConfig_exec_path = '/usr/bin/editorconfig'

" basics
set nocompatible        " use vim defaults
set mouse=a             " make sure mouse is used in all cases.
set fileformat=unix     " force unix-style line breaks
set tabpagemax=30       " maximum number of tabs
" tabs and indenting
"set expandtab           " insert spaces instead of tab chars
set tabstop=8          " a n-space tab width
set shiftwidth=8        " allows the use of < and > for VISUAL indenting
set softtabstop=0       " counts n spaces when DELETE or BCKSPCE is used
set fileencoding=utf-8

if has("autocmd")
  filetype plugin indent on " indents behaviour depends on type
else
  set autoindent        " auto indents next new line
endif

set cinoptions=t0,g0,(0,:0

" searching
set nohlsearch          " dont highlight all search results
set incsearch           " increment search
set ignorecase          " case-insensitive search
set smartcase           " upper-case sensitive search

" formatting
set backspace=2         " full backspacing capabilities
set history=100         " 100 lines of command line history
set cmdheight=1         " command line height
set laststatus=2        " occasions to show status line, 2=always.
set ruler               " ruler display in status line
set showmode            " show mode at bottom of screen
set showcmd             " display some infos (in visual)

set number              " show line numbers
set nobackup            " disable backup files (filename~)
set showmatch           " show matching brackets (),{},[]
set ww=<,>,[,]          " whichwrap -- left/right keys can traverse up/down

" search tags-file in the opened file's dir and if not found recursiveley
set tags=./tags;

" syntax highlighting
syntax on               " enable syntax highlighting

let NERDTreeShowHidden=1

" highlight redundant whitespaces and tabs.
"highlight RedundantSpaces ctermbg=red guibg=red
"match RedundantSpaces /\s\+$\| \+\ze\t\|\t/

" gvim settings
set guioptions=aeicv
set guifont=Dejavu\ Sans\ Mono\ 10 " backslash spaces
"set lines=30
"set columns=95

" F5 toggles spell checking
:map <F5> :setlocal spell! spelllang=de_de<cr>
:imap <F5> <C-o>:setlocal spell! spelllang=de_de<cr>

:map <F9> :make<cr>
:imap <F9> <C-o>:make<cr>

" common save shortcuts ~ dont work with vim :(
"inoremap <C-s> <esc>:w<cr>a
"nnoremap <C-s> :w<cr>

" Mapping for Copy/Paste
map <C-x> "+x
map <C-y> "+y
map <C-p> "+p
" enter ex mode with semi-colon
nnoremap ; :
vnoremap ; :

" strip ^M linebreaks from dos formatted files
map M :%s/
$//g

" use Tab to switch between current and last buffer
nmap <Tab> :b#<CR>

map <C-n> :NERDTreeToggle<CR>

" mutt rules
autocmd BufRead /tmp/mutt-* set tw=72 spell

" load build-in man page viewer command
runtime ftplugin/man.vim

" set bash syntax - pressed v in bash-vi mode
au BufRead,BufNewFile /tmp/bash-* let is_bash=1|setfiletype sh

" mesa project specific settings
autocmd BufNewFile,BufRead /home/ben/src/mesa*/*{c,h,cpp} set sw=3 ts=8 sts=3 et
autocmd BufNewFile,BufRead /home/ben/src/mesa*/Makefile.* set ft=make
autocmd BufNewFile,BufRead /home/ben/src/mesa*/SCons* set ft=python sw=4 sts=4 ts=4 et
autocmd BufNewFile,BufRead /home/ben/src/mesa*/configure.ac set sw=4 sts=4 ts=8 et

" wayland project specific settings
autocmd BufNewFile,BufRead /home/ben/src/wayland/*xml set sw=2 ts=8 sts=2 et

" sssd
autocmd BufNewFile,BufRead /home/ben/src/sssd/*{c,h,cpp} set sw=4 ts=8 sts=4 et

" sqlbox
autocmd BufNewFile,BufRead /home/ben/studium/mmp/sqlbox/*xml set sw=2 ts=8 sts=2 et
autocmd BufNewFile,BufRead /home/ben/studium/mmp/sqlbox/*php set sw=4 ts=8 sts=4 et

" settings for web projects
autocmd BufNewFile,BufRead /home/ben/htdocs/mutti-web/*{xsl,xml} set sw=2 ts=8 sts=2 et
"
" settings for web projects
autocmd BufNewFile,BufRead /home/ben/src/qbcontact/*{php,html} set sw=4 ts=4 sts=4

" settings for systemd
autocmd BufNewFile,BufRead /home/ben/src/systemd/* set sw=8 ts=8 sts=8 et
autocmd BufNewFile,BufRead /home/ben/src/systemd/man/*.xml set sw=2 ts=2 sts=2 et

" vimmanpager stuff
" disable line numbers when using vim as manpager
autocmd FileType man set nonumber nohlsearch nohlsearch

"colorscheme tango
"set background=light

autocmd FileType tex colorscheme delek
"autocmd FileType asciidoc colorscheme inkpot

set spellfile=$HOME/.config/vim/spell/spell.de.add,$HOME/vim/spell/spell.en.add


highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
" Show trailing whitespace and spaces before a tab:
"match ExtraWhitespace /\s\+$\| \+\ze\t/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

" alt mapping seems to only work in gvim
:map <A-h> :tabprevious<cr>
:map <A-l> :tabnext<cr>
:map <A-Left> :tabprevious<cr>
:map <A-Right> :tabnext<cr>
:map <XF86Forward> :tabnext<cr>

call pathogen#infect()

colorscheme tangoX

set noerrorbells
set visualbell
" Turn of visualbell screen flashing
set t_vb=
"
" its important that viminfo is set at the end
" some options seem to overwrite this (history..)
set viminfo+=n/home/ben/.cache/vim/viminfo