summaryrefslogtreecommitdiffstats
path: root/vimrc
blob: 4c7530d223d5e27ee7d3b7effcc0e846a421c3a4 (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
" vim configuration of Sebastian Reichel <sre@ring0.de>

set nocompatible					" vim native mode
syntax on							" enable syntax highlighting
colorscheme elektranox              " cool colors
set hlsearch						" highlight searched word
set number							" numberize lines
set ruler							" lower file
set nowrap							" do not wrap lines
set incsearch						" search while typing
set foldmethod=syntax				" automatic code-folding
set autoindent						" automatic indention
set noerrorbells visualbell t_vb=	" no audible bell
set mouse=a							" set mouse to auto
set ruler							" show cursor position all the time
set wildmode=longest,list			" setup wildmode
set showmatch						" show matching brackets
set encoding=utf-8					" UTF-8
set iskeyword-=_					" _ is a word delimiter
set autoread

" http://d.hatena.ne.jp/fuenor/20110705/1309866529
au InsertLeave * call PyIBusDisable()
function! PyIBusDisable()
python << EOF
import ibus
bus = ibus.Bus()
ic = ibus.InputContext(bus, bus.current_input_contxt())
ic.disable()
EOF
endfunction

" Configure the status line show something useful.
"set statusline=%F%m%r%h%w\ %y\ [%{&ff}]%=[%l,%v][%p%%]\ [%L]
"set laststatus=2    " Ensure status line is visible.

" Sane handling of whitespace.
set tabstop=4
set shiftwidth=4
set softtabstop=4

" The h and l keystrokes can be made to wrap over lines (so that trying to
" move left past the beginning of a line puts the cursor at the end of the
" line above). This command does that, and also allows ~ (convert case) to
" wrap over lines, and the cursor keys to wrap when in insert mode:
set whichwrap=h,l,~,[,]

" Get useful auto-completion in command mode.
set wildmenu
set wildmode=list:longest,full

" copy&paste via <F4>
nnoremap \tp :set invpaste paste?<CR>
nmap <F4> \tp
imap <F4> <C-O>\tp
set pastetoggle=<F4>

" clear search via <F5>
nnoremap \clearsearch :let @/ = ""<CR>
nmap <F5> \clearsearch
imap <F5> <C-O>\clearsearch

" compile latex/code via <F6>
nnoremap \make :!make<CR>
nmap <F6> \make
imap <F6> <C-O>\make

" add vala support
autocmd BufRead *.vala   set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
autocmd BufRead *.vapi   set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
autocmd BufRead *.gtkaml set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
au BufRead,BufNewFile *.vala            setfiletype vala
au BufRead,BufNewFile *.vapi            setfiletype vala
au BufRead,BufNewFile *.gtkaml          setfiletype vala
let vala_comment_strings = 1
let vala_comment_ifdef = 1
"let vala_space_errors = 1

" add support for subtitle files
au BufNewFile,BufRead *.ssa setf ssa
au BufNewFile,BufRead *.ass setf ssa

" configure printing stuff
set pdev=Default											" printer device
set printoptions=paper:A4,syntax:n,wrap:y,duplex:long		" print options
set penc=utf-8												" print encoding
"set pfn=courier:h10										" print font
"set pheader=...											" print header

" set terminal title
if &term == "screen"
  set t_ts=k
  set t_fs=\
endif
if &term == "screen" || &term == "xterm"
  set title
endif

" Set a nicer foldtext function
set foldtext=MyFoldText()
function! MyFoldText()
	let line = getline(v:foldstart)
	if match( line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$' ) == 0
		let initial = substitute( line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '' )
		let linenum = v:foldstart + 1
		while linenum < v:foldend
			let line = getline( linenum )
			let comment_content = substitute( line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g' )
			if comment_content != ''
				break
			endif
			let linenum = linenum + 1
		endwhile
		let sub = initial . ' ' . comment_content
	else
		let sub = line
		let startbrace = substitute( line, '^.*{[ \t]*$', '{', 'g')
		if startbrace == '{'
			let line = getline(v:foldend)
			let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g')
			if endbrace == '}'
				let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', '...}\1', 'g')
			endif
		endif
	endif
	let n = v:foldend - v:foldstart + 1
	let info = " " . n . " lines"
	let sub = sub . "                                                                                                                  "
	let num_w = getwinvar( 0, '&number' ) * getwinvar( 0, '&numberwidth' )
	let fold_w = getwinvar( 0, '&foldcolumn' )
	let sub = strpart( sub, 0, winwidth(0) - strlen( info ) - num_w - fold_w - 1 )
	return sub . info
endfunction

" open epub files as zip
au BufReadCmd   *.epub      call zip#Browse(expand("<amatch>"))

" enable plugins depending on filetype
filetype plugin on

" git branch in ruler
set rulerformat=%33(%{fugitive#statusline()}%=%10(%l,%c%V%=%5(%p%%%)%)%)

" copy & paste
vmap <C-c> y: call system("xclip -i -selection clipboard", getreg("\""))<CR>
nmap <C-v> :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p

" debian/control indents must be spaces
autocmd FileType debcontrol set expandtab

au BufRead,BufNewFile *.nc            setfiletype nc