summaryrefslogtreecommitdiffstats
path: root/.vimrc (plain)
blob: 8f2f7fba12e031ab2f838409686d458a934a80b9
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
" 
" Lucas de Vries' .vimrc
" Nick: GGLucas
" Mail: lucas@glacicle.com
" Website: lucas.glacicle.com
"

" {{{ Key Mappings
" Leader
let mapleader=","

" {{{ Window/split navigation
nmap <Esc>h <C-w>h
nmap <Esc>j <C-w>j
nmap <Esc>k <C-w>k
nmap <Esc>l <C-w>l
nmap <Esc>n <C-w>W
nmap <Esc>t <C-w>w
" }}}

" {{{ Basic shortcuts
" Handy shortcut for save
noremap <Leader>e e
noremap <silent> e :w<CR>

" Meta-o for inserting a blank line
noremap <Esc>o o<Esc>

" O mappings for not inserting the comment leader
noremap go o<Esc>S
noremap gO O<Esc>S

" To prevent annoying mispresses
vmap K k
nmap Q <Nop>

" Use ,, to work around , as leader
noremap ,, ,

" Return to visual mode after indenting
vmap < <gv
vmap > >gv

" Faster scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>

" Search for word under cursor without moving
noremap <Leader># #*
noremap <Leader>* *#

" Clear screen and remove highlighting
nnoremap <silent> <Esc><C-l> :nohl<CR><C-l>
nnoremap <silent> <C-l> :nohl<CR>

" Prompt for a filetype to set
nmap <silent> <Esc>@ :call PromptFT()<CR>

" Quickly send keys to a screen session through slime.vim
" Allows for test-execution of scripts and whatnot without leaving vim.
nmap <C-c>m :call Send_to_Screen("<C-v>
")<CR>
nmap <C-c>c :call Send_to_Screen("<C-v>OA<C-v>
")<CR>
nmap <C-c>r :call Send_to_Screen(input("send to screen: ")."<C-v>
")<CR>
nmap <C-c>g :call Send_to_Screen(input("send to screen: "))<CR>

" }}}

" {{{ Spellcheck
nmap <Leader>ss :set nospell<CR>
nmap <Leader>se :set spell spelllang=en<CR>
nmap <Leader>sn :set spell spelllang=nl<CR>
" }}}

" {{{ Buffer Navigation
nnoremap <silent> <Esc>c :A<CR>
nnoremap <silent> <Esc>g :FufBuffer<CR>
nnoremap <silent> <Esc>f :FufTag<CR>
nnoremap <silent> <Esc>b :e .<CR>

nnoremap <silent> <Esc>w :bnext<CR>
nnoremap <silent> <Esc>v :bprev<CR>
" }}}

" {{{ Opening different plugin windows
nmap <silent> <Leader>n :call TreeOpenFocus()<CR>
nmap <silent> <Leader>N :NERDTreeToggle<CR>
nmap <silent> <Leader>t :TlistOpen<CR>
nmap <silent> <Leader>T :TlistToggle<CR>
nmap <silent> <Leader>s :SessionList<CR>
nmap <silent> <Leader>S :SessionSave<CR>

nmap <silent> <Leader>j :source ~/.vim/scripts/sparkup.vim<CR>
nmap <silent> <Leader>d :Bclose<CR>
nmap <silent> <Leader>bd :Bclose!<CR>

nmap <Leader>h :vert bo help 
" }}}

" {{{ Command line cursor keys
cnoremap <C-H> <Left>
cnoremap <C-L> <Right>
cnoremap <C-X> <Delete>
cnoremap <C-J> <Down>
cnoremap <C-K> <Up>
cnoremap <Esc>j <Down>
cnoremap <Esc>k <Up>
cnoremap <Esc>c <C-c>:
" }}}

" {{{ Function key shortcuts
" F5: Toggle paste mode
nnoremap <F5> :set paste!<Bar>set paste?<CR>
imap <F5> <C-O><F5>
set pastetoggle=<F5>

" F6: Toggle whether to use textwidth or not
nnoremap <F6> :call TextwidthToggle()<CR>
imap <F6> <C-O><F6>

" F7: Turn search highlight off until next search
nmap <F7> :noh<CR>
imap <F7> <C-O><F7>

" F8: Toggle list mode
nmap <F8> :set list!<Bar>set list?<CR>
imap <F8> <C-O><F8>

" F9: Toggle highlighting long lines
nmap <F9> :call HighlightLongToggle()<CR>
imap <F9> <C-O><F9>
" }}}
" }}}

" {{{ Plugin Settings
" NERD Commenter
let NERDDefaultNesting = 1

" NERD Tree
let NERDTreeIgnore = ['\~$', '\.pyc$', '\.swp$', '\.class$', '\.o$']
let NERDTreeSortOrder = ['\/$', '\.[ch]$', '\.py$', '*']

" Taglist
let Tlist_Use_Right_Window = 1
let Tlist_GainFocus_On_ToggleOpen = 1

" Pydoc
let g:pydoc_highlight = 0

" Python syntax
let python_highlight_all = 1
let python_highlight_space_errors = 0

" Buffer tabs in statusline
let g:buftabs_active_highlight_group = "Visual"
let g:buftabs_in_statusline = 1
let g:buftabs_only_basename = 1

" Use fancy css for TOhtml
let html_use_css = 1

" Fuzzy finder
let g:fuf_previewHeight = 0

" }}}

" {{{ Vim Settings
" Color Schemes
if $TERM == 'linux'
    " Virtual Console
    colorscheme default
else
    " Oblivion
    set t_Co=256
    colorscheme oblivion
endif

" Config
" Use UTF-8 encoding
set encoding=utf-8

" Don't highlight the current line
set nocursorline

" Characters to use in list mode
set listchars=tab:▸\ ,trail:·
set list

" Enter spaces when tab is pressed:
set expandtab

" Always display statusline
set laststatus=2

" Statusline information
set statusline=%=%P\ 

" Text width
let g:textwidth=0
set textwidth=0

" Wrap lines
set wrap

" Use 4 spaces to represent a tab
set tabstop=4
set softtabstop=4

" Number of spaces to use for auto indent
set shiftwidth=4

" Copy indent from current line when starting a new line
set autoindent

" Makes the backspace key more powerful
set backspace=indent,eol,start

" Shows the match while typing
set incsearch

" Case insensitive search
set ignorecase
set smartcase

" Show line and column number
set number
set ruler

" Allow hidden buffers with changes
set hidden

" Automatically switch to the directory we're editing in
set autochdir

" Show matching
set showmatch

" Remember history
set history=100

" Scrolloff
set scrolloff=3

" Shortmess
set shortmess=atI

" Swap files
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp

" Use actual block mode for visual block
set virtualedit=block

" Viminfo
set viminfo='100,f1,<50,:50,/50,h,!

" Global match by default
set gdefault

" Format (gq) options
set formatoptions+=w

" Highlight search
set hls

" Don't fold less than 2 lines
set foldminlines=2

" Filetype
filetype on
filetype plugin on
filetype indent on

" Syntax highlighting
syntax on
" }}}

" {{{ Autocommands
" Read-only .doc through antiword
autocmd BufReadPre *.doc silent set ro
autocmd BufReadPost *.doc silent %!antiword "%"

" Read-only odt/odp through odt2txt
autocmd BufReadPre *.odt,*.odp silent set ro
autocmd BufReadPost *.odt,*.odp silent %!odt2txt "%"

" Read-only pdf through pdftotext
autocmd BufReadPre *.pdf silent set ro
autocmd BufReadPost *.pdf silent %!pdftotext -nopgbrk -layout -q -eol unix "%" - | fmt -w78

" Read-only rtf through unrtf
autocmd BufReadPre *.rtf silent set ro
autocmd BufReadPost *.rtf silent %!unrtf --text

" HTML Indent
autocmd FileType xhtml,html,xml,sass silent setlocal tabstop=2 softtabstop=2 shiftwidth=2

" Load sparkup for html
autocmd FileType xhtml,html,xml,markdown silent source ~/.vim/scripts/sparkup.vim

" Set correct folding
autocmd FileType c silent setlocal fdm=syntax fdn=1

" Highlight "self" in python
autocmd FileType python syn keyword Identifier self

" Highlight braces with braces style
autocmd FileType xhtml,html hi link htmlEndTag BoldBraces
autocmd FileType xml hi link xmlEndTag BoldBraces
autocmd FileType javascript hi link javaScriptBraces Braces

" Set markdown syntax
autocmd BufNewFile,BufRead *.{md,mkd,mark,markdown} set ft=markdown

" Highlight long lines
autocmd BufRead * let w:longmatch = matchadd('MoreMsg', '\%<81v.\%>77v', -1)
autocmd BufRead * let w:toolongmatch = matchadd('Folded', '\%>80v.\+', -1)

" Highlight dirslash correctly
hi link treeDirSlash Function

" Jump to last known cursor position
autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

" }}}

" {{{ Functions
" {{{ TextwidthToggle(): Change textwidth, 0<->78
function! TextwidthToggle()
    if g:textwidth == 0
        let g:textwidth = 78
        set textwidth=78
    else
        let g:textwidth = 0
        set textwidth=0
    endif

    set textwidth?
endfunction
" }}}

" {{{ HighlightLongToggl(): Toggle highlighting of long lines
function! HighlightLongToggle()
    if exists('w:longmatch')
        call matchdelete(w:longmatch)
        call matchdelete(w:toolongmatch)
        unlet w:longmatch
        unlet w:toolongmatch
        echo "  don't highlight long"
    else
        let w:longmatch = matchadd('MoreMsg', '\%<81v.\%>77v', -1)
        let w:toolongmatch = matchadd('Folded', '\%>80v.\+', -1)
        echo "  highlight long"
    endif
endfunction
" }}}

" {{{ TreeOpenFocus(): Open the nerd tree or focus it.
function! TreeOpenFocus()
    let wnr = bufwinnr("NERD_tree_1")
    if wnr == -1
        :NERDTreeToggle
    else
        exec wnr."wincmd w"
    endif
endfunction
" }}}

" {{{ PromptFT(): Prompt for a new filetype to set
function! PromptFT()
    let ft=input("Filetype: ")
    exec "setlocal ft=".ft
endfunction
" }}}
" }}}
" vim:fdm=marker