-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
161 lines (135 loc) · 4.33 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
157
158
159
160
161
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Override of Defaults
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Show the title, ruler, status, mode and line numbers
set showmode
set laststatus=2
set number
set title
set ruler
" This is what files look like
set encoding=utf8
set ffs=unix,dos,mac
" From whence you came, you shall remain, until you set, the path again
set path=$PWD/**
" Tab sanity
set expandtab
set smarttab
set tabstop=4
set shiftwidth=4
set backspace+=start,eol,indent
" Alas Master Wq, Master Git's wushu is greater
" (I don't really need this backup or swapfile stuff thanks to DVC)
set autoread
set nobackup
set nowb
set noswapfile
" Keep lots of history/undo
set history=1000
set undolevels=1000
" Use filetype in lieu of compatible if available
if has("autocmd")
filetype on
filetype indent on
filetype plugin on
set nocompatible
endif
" Syntax highlighting
syntax enable
" Enable folding but leave it unfolded by default
set foldmethod=indent
set foldlevel=30
" Fold commands
" zR open all folds
" zM close all folds
" za toggle fold at cursor position
" zj move down to start of next fold
" zk move up to end of previous fold
" Highlight red for trailing white space after insert or for line too long
highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufWinEnter * match ExtraWhitespace /\s\+$\|\%80v.\+/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$\|\%80v.\+/
autocmd InsertLeave * match ExtraWhitespace /\s\+$\|\%80v.\+/
autocmd BufWinLeave * call clearmatches()
" Make the background dark and the foreground colorful
set bg=dark
set t_Co=256
" Highlight search, show the matches as the search term is typed, and
" highlight matching punctuation
set hlsearch
set incsearch
set mat=2
set showmatch
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Key Mappings
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Pretend arrow keys don't exist - (No cheating!)
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
vnoremap <up> <nop>
vnoremap <down> <nop>
vnoremap <left> <nop>
vnoremap <right> <nop>
" Put escape on the home row
inoremap jk <esc>
inoremap kj <esc>
" Define leader key
let mapleader = ","
" Define leader commands:
" Make leader space clear search
nnoremap <leader><space> :noh<cr>
nnoremap <leader>w :call StripTrailingWhitespaces()<cr>
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Plugin Bootstrap and Configuration
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Set up Vundle on first install - Vundle, in turn, installs all other plugins
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"List bundles here
Bundle 'gmarik/vundle'
Bundle 'scrooloose/syntastic'
Bundle 'pfdevilliers/Pretty-Vim-Python'
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
" end of vundle setup
" Syntastic Configuration
let g:syntastic_python_checkers = ['pyflakes']
let g:syntastic_c_checkers = ['splint']
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Custom Functions
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" Whitespace
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" A function to strip trailing whitespace and clean up afterwards so
" that the search history remains intact and cursor does not move.
" Taken from: http://vimcasts.org/episodes/tidying-whitespace
" Taken in turn from: https://github.com/nrb/dotfiles/blob/master/.vimrc
function! StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction