summaryrefslogtreecommitdiff
path: root/vim/.vimrc
blob: 8a101367ada775d1e348c0f34436ab2dd66f3ac2 (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
" utf8. always utf8.
set fileencoding=utf8
set fileencodings=utf8

" these seem reasonable
set tabstop=4
set softtabstop=4
set shiftwidth=4

" remove trailing whitespace when saving
function StripTrailingWhitespace()
	if !&binary && &filetype != 'diff'
		normal mz
		normal Hmy
		%s/\s\+$//e
		normal 'yz<CR>
		normal `z
	endif
endfunction

autocmd BufWritePre * :call StripTrailingWhitespace()

" display absolute line numbers in insert mode, relative otherwise
" allow ^N to toggle between them on demand
function! NumberToggle()
	if(&relativenumber == 1)
		set number
	else
		set relativenumber
	endif
endfunc

nnoremap <C-n> :call NumberToggle()<cr>

set relativenumber
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber