-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
156 lines (121 loc) · 4.73 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
" Random vim config collected and handed over through the years at the Student
" Society in Trondheim
" Now mine.
set nocompatible " Use Vim defaults, not annoying vi. It resets some variables so do it first.
filetype plugin indent on
syntax on
let osys=system('uname -s')
let vimdir=$HOME . '/.vim/'
" Store all backup files in a central folder instead of cluttering
let &viminfo="'10000," . '%,n' . vimdir . 'viminfo'
let &backupdir=vimdir . 'tmp'
" Stop whining when setting up on a new machine
if !isdirectory(&backupdir)
call mkdir(&backupdir, "p")
endif
" If we have a saved position in the file, go there.
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
set backup " Keep a backup file
set errorbells " beep/flash on errors
set history=10000 " keep 10000 lines of command history (already done above with viminfo, but w/e)
set nowrap " fuckg wrapping
set number " show line numbers
set nowarn " I don't care
set ruler " Show the cursor position all the time
set suffixes+=.class,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set showcmd " show last command
set showmatch " show matching brace when inserting
set shortmess=at " shortens messages to avoid 'press a key' prompt
set diffopt+=iwhite " ignore trailing whitespace in vimdiff
set novisualbell " just let the terminal blink
set wildmode=list:longest " file-listing when opening a directory
" Folding
set foldmethod=manual " I don't trust people
set foldlevelstart=99 " start with all folds open
set foldopen-=search " don't open folds when you search into them
set foldopen-=undo " don't open folds when you undo stuff
" Input
set timeout " allow keys to timeout
set ttimeoutlen=100 " Timeout of successive keys from keyboard driver, avoid annoying delays
" Indentation
set ai " Always set auto-indenting on
set backspace=2 " Allow backspacing over everything in insert mode
set expandtab " expand tabs to spaces
set tabstop=8 " be very explicit when people are annoying
set softtabstop=4
set shiftwidth=4
" Search
set hlsearch " highlight last search
set smartcase " search good
set ignorecase " ignore case by default
set scrolloff=5 " show some context around the search result
" latex-suite wants grep to always generate a file-name.
set grepprg=grep\ -nH\ $*
" Disable autoloading of vimspell
let loaded_vimspell = 1
let spell_insert_mode = 0
let spell_auto_type = "tex,mail"
let spell_language_list = "norsk,english"
" vim doesn't handle escape codes in the output very well
set makeprg=CFLAGS=-fdiagnostics-color=never\ CXXFLAGS=-fdiagnostics-color=never\ make
" F1 for help is really annoying.
:nmap <F1> :echo<CR>
:imap <F1> <C-o>:echo<CR>
:nmap q :echo<CR>
" Misstyping ; is annoying
:nnoremap ; :
" Because I type this wrong all the time
:command Q q
:command Qall qall
" Redraw screen and clear search highlight
nnoremap <silent> <C-l> :nohl<CR><C-l>
" Ctrl+tab navigation for tabs, like in all other application
nnoremap <C-S-tab> :tabprevious<CR>
nnoremap <C-T> :tabnext<CR>
nnoremap <C-t> :tabnew<CR>
inoremap <C-S-tab> <Esc>:tabprevious<CR>i
inoremap <C-tab> <Esc>:tabnext<CR>i
inoremap <C-t> <Esc>:tabnew<CR>
"" Change directory to the directory of the file I'm working on.
"autocmd BufEnter *
" \ if isdirectory( '%:p:h' ) |
" \ lcd %:p:h |
" \ endif
" Set a satusline that gives some cool information.
set statusline=%<%F%h%m%r%=\[%B\]\ %l,%c%V\ %P
" Always show the statusline
set laststatus=2
" Don't use Ex mode, use Q for formatting
map Q gq
let g:Tex_DefaultTargetFormat="dvi"
" We play utf-8
set fileencoding=utf-8
set encoding=utf-8
set termencoding=utf-8
au BufNewFile,BufRead mutt* set tw=77 ai nocindent fileencoding=utf-8
au BufNewFile,BufRead psql.edit.* set tw=77 ai nocindent fileencoding=utf-8 filetype=sql
" The PKGBUILD highlighting in pacman-contrib is broken, so pretend they are
" normal shell scripts
au BufNewFile,BufRead PKGBUILD set filetype=sh
" Open multiple files in new tabs
au VimEnter * if !&diff | tab all | tabfirst | endif
" Colors
" dark background good
set background=dark
" Highlight bogus whitespace at the end of files
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
" Make spelling errors readable
highlight SpellBad ctermbg=0 ctermfg=1
" Make diffs readable, darker backgrounds
" - darkest red
highlight DiffText ctermbg=88
" - dark pink
highlight DiffChange ctermbg=54
" - navy blue, darkest blue I could find
highlight DiffAdd ctermbg=17
" - dark green
highlight DiffDelete ctermbg=22