summaryrefslogtreecommitdiffstats
path: root/.vimrc
blob: 85195e4d55b14ab7f4c1d5f934dbdf236e05fbd6 (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
"----------------------------------------------------
" File:         .vimrc 
" Version:      0.1.1
" Author:       Florian "Bluewind" Pritz <f-p@gmx.at>
"----------------------------------------------------
set nocompatible
set encoding=utf-8               " unicode encoding
if &term =~# '^\(screen\|rxvt*\)$' "tty blinks otherwise
  set t_Co=256
endif
set nobackup
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set ruler                        " show me where the cursor is
set rulerformat=%l/%L(%p%%),%c   " a better ruler
set showmatch                    " show matching brackets 
set cindent
set number                       " show line numbers
set showmode                     " show mode at bottom of screen
set hlsearch                     " highlight all search results
set incsearch                    " increment search
set ignorecase                   " case-insensitive search
set smartcase                    " upper-case sensitive search
set laststatus=2
set mouse=a                     
set nopaste
set foldmethod=marker
set autoindent
set scrolloff=3
set showcmd
set display=uhex

let g:qname_hotkey = "<C-b>"

syntax on

filetype plugin indent on

autocmd FileType text setlocal textwidth=78
autocmd BufReadPost *
  \ if line("'\"") > 1 && line("'\"") <= line("$") |
  \   exe "normal! g`\"" |
  \ endif

if !exists(":DiffOrig")
  command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
	  \ | wincmd p | diffthis
endif

" Comment out a visual block
function CommentLines()
    execute ":s@^@".g:StartComment." @g"
    "execute ":s@^\\(\\s*\\)@\\1".g:StartComment." @g"

    execute ":s@$@ ".g:EndComment."@g"
endfunction

" Uncomment a visual block
function UncommentLines()
    execute ":s@^".g:StartComment." @\@g"
    "execute ":s@^\\(\\s*\\)".g:StartComment." @\\1@g"

    execute ":s@ ".g:EndComment."$@@g"
endfunction

" Set comment characters for common languages
autocmd FileType python,sh,bash,zsh,ruby,perl let StartComment="#" | let EndComment=""
autocmd FileType html let StartComment="<!--" | let EndComment="-->"
autocmd FileType php,c,javascript let StartComment="//" | let EndComment=""
autocmd FileType cpp let StartComment="/*" | let EndComment="*/"
autocmd FileType vim let StartComment="\"" | let EndComment=""

vmap <C-c> :call CommentLines()<cr>
vmap <C-u> :call UncommentLines()<cr>

set runtimepath+=/usr/share/vim

"inoremap <tab> <c-n>

let python_highlight_all = 1

" common save shortcuts
inoremap <C-s> <esc>:w<cr>a
nnoremap <C-s> :w<cr>
inoremap <C-c> <esc>:q<cr>a
nnoremap <C-c> :q<cr>

"au VimEnter * :NERDTreeToggle
noremap <F2> :NERDTreeToggle<CR>
inoremap <F2> <ESC>:NERDTreeToggle<CR>

noremap <C-f> :FuzzyFinderFile<CR>
inoremap <C-f> <ESC>:FuzzyFinderFile<CR>
"noremap <C-b> :FuzzyFinderBuffer<CR>
"inoremap <C-b> <ESC>:FuzzyFinderBuffer<CR>

noremap <C-h> :nohl<CR>
inoremap <C-h> <ESC>:nohl<CR>a

autocmd FileType make setlocal noexpandtab
au FileType python set ts=4 sw=4 softtabstop=4 et

"colorscheme gardener
"colorscheme desert256
"colorscheme candycode
"colorscheme jellybeans
"colorscheme inkpot
"colorscheme mustang
colorscheme wombat256

" Toggle dark/light default colour theme for shitty terms
"map <F2> :let &background = ( &background == "dark" ? "light" : "dark" )<CR>

" Compile and run keymappings
au FileType php map <F4> :!php %<CR>
au FileType python map <F4> :!python %<CR>
au FileType perl map <F4> :!perl %<CR>
au FileType ruby map <F4> :!ruby %<CR>
au FileType lua map <F4> :!lua %<CR>
au FileType html,xhtml map <F4> :!firefox %<CR>
au FileType tex map <F4> :!texi2pdf -c %<CR>

" MiniBufExplorer
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplMapWindowNavArrows = 1
"let g:miniBufExplMapCTabSwitchBufs = 1
"let g:miniBufExplModSelTarget = 1 

"set tags+=$HOME/.vim/tags/python.ctags

map <F12> <ESC>ggg?G``" apply rot13 for people snooping over shoulder, good fun

if !has("gui_running")
  if &term == "screen"
    set <C-Right>=Oc
    set <C-Left>=Od
    imap <C-Right> <ESC>:bn<RETURN>
    imap <C-Left> <ESC>:bp<RETURN>
  endif
endif

if has("gui_running")
  set guifont=Dejavu\ Sans\ Mono\ 7
  "set guioptions-=m
  set guioptions-=T
  set lines=45 columns=125
endif