-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
300 lines (226 loc) · 6.07 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
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
"{{{ VIM BUNDLES
" Vim, not Vi!
set nocompatible
" Required to setup Vundle
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Sensible vim plugins
Bundle "tpope/vim-sensible"
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
" This plugin automatically reloads changed vim scripts in the current vim
" session. I like this because it makes it simple to add changes to
" vim/ftplugin/*.vim files and have the changes appear immediately.
Bundle 'xolox/vim-misc'
Bundle 'xolox/vim-reload'
" Nice colorscheme for vim
Bundle 'altercation/vim-colors-solarized'
" Faster file searching
Bundle 'kien/ctrlp.vim'
" Indent, syntax and detect files for clojure
Bundle 'guns/vim-clojure-static'
Bundle 'kien/rainbow_parentheses.vim'
" Useful for aligning columns of text
Bundle 'vim-scripts/Align'
" Good for matching parentheses in lisps
Bundle 'vim-scripts/paredit.vim'
" Fast movement around file
Bundle 'Lokaltog/vim-easymotion'
" Default status line for vim
Bundle 'bling/vim-airline'
" Interactive clojure repl for vim
Bundle 'tpope/vim-fireplace'
" Syntax highlighting for Dockerfiles
Bundle "ekalinin/Dockerfile.vim"
" Seemless navigation between vim and tmux windows
Bundle 'christoomey/vim-tmux-navigator'
" Manage git repositories inside vim
Bundle 'tpope/vim-fugitive'
" Syntax highlighting for less file
Bundle 'groenewege/vim-less'
" GPG encrypted file
Bundle 'jamessan/vim-gnupg'
" Additional text objects for vim
Bundle 'wellle/targets.vim'
" Show list of buffers
Plugin 'bling/vim-bufferline'
"}}}
"{{{ GENERAL CONFIG
" I don't use swap files
set noswapfile
" Map leader key to comma
let mapleader = ","
" Modelines are a security risk
set modelines=0
" Don't try to use screen/tmux as a shell
set shell=/bin/sh
" Specify language
language en_GB.UTF-8
" Set temporary directory for swp/tmp files
set directory=$HOME/.vim/tmp
" Set large history size
set hi=1000
" Flash instead of beep
set visualbell
" Use grep instead of ack
set grepprg=ack
" Don't add spaces when joining lines
set nojoinspaces
" Stronger file encryption
set cryptmethod=blowfish
" Do not display vim start-up text
set shortmess+=I
" Use system clipboard
set clipboard=unnamed
" Write buffers without prompting
set autowrite
if v:version >= 703
" Keep undo file of previous actions
set undofile
set undodir=$HOME/.vim/tmp
set colorcolumn=85 " Highlight when line reaches this length
endif
" }}}
" {{{ MOVEMENT
let g:EasyMotion_leader_key = '<Space>'
" Highlight search matches
set hlsearch
" N rows at top and bottom of screen
set scrolloff=9999
" }}}
" {{{ APPEARANCE
let g:solarized_termcolors = 256
let g:solarized_termtrans = 1
colorscheme solarized
" Add number column on left-hand side
set number
set cursorline
set background=dark
highlight clear CursorLine
highlight CursorLine term=underline cterm=underline
" Enable viewing of fancy characters
set encoding=utf-8
" Use patched fonts for powerline status bar
let g:airline_powerline_fonts = 1
" }}}
" {{{ FUNCTIONS
" Insert ISO-8601 date
function! Iso8601Date()
set formatoptions-=a
r!date "+\%FT\%TZ"
set formatoptions+=a
endfunction
" Insert human readable date
function! HumanDate()
r!date
endfunction
" Removes trailing spaces
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
autocmd BufWritePre * :call TrimWhiteSpace()
"}}}
"{{{ FILETYPES
set wildignore=*.pyc,*.egg-info/*
au BufNewFile,BufRead *.muttrc set filetype=muttrc
au BufNewFile,BufRead GHI_*,*.md,*.Rmd set filetype=markdown
au BufNewFile,BufRead Vagrantfile set filetype=ruby
au BufNewFile,BufRead *.cwl set filetype=yaml
autocmd User GnuPG setfiletype markdown
" }}}
" {{{ GUI
set guifont=Inconsolata:h17.00
set guioptions-=T " Remove toolbar
set guioptions+=c " Use console dialogs
set guioptions-=lLrR " Remove scroll bars
if has('gui_running')
let &columns = 90 " Number of columns in window
endif
" }}}
" {{{ GENERAL KEY MAPS
" Train myself not to use the home row keys to move around
map h <nop>
map l <nop>
" Up motion
map k <Plug>(easymotion-bd-b)
" Down motion
map j <Plug>(easymotion-bd-w)
" Faster Esc
inoremap jj <ESC>
" Double leader writes the file
nnoremap <leader><leader> <Esc>:w<CR>
" Prevent from entering Ex mode
nnoremap Q <nop>
" }}}
"{{{ ARROW KEY MAPS
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" }}}
"{{{ LEADER KEY MAPS
" {{{ UPPER LEFT
nnoremap <leader>q <ESC>:1<CR>a= <ESC>:call HumanDate()<CR>0bJA =<CR><CR><ESC>
nnoremap <leader>w <nop>
nnoremap <leader>e <nop>
nnoremap <leader>E <nop>
nnoremap <leader>r <nop>
nnoremap <leader>t <nop>
" }}}
" {{{ HOME LEFT
nnoremap <leader>a <nop>
nnoremap <leader>s <nop>
nnoremap <leader>d <nop>
nnoremap <leader>f :nohlsearch<CR>
nnoremap <leader>g :b#<CR> " Switch to the last used buffer
" }}} {{{ LOWER LEFT
" Pull current word into S&R
nnoremap <leader>z :%s#\<<C-r>=expand("<cword>")<CR>\>#
nnoremap <leader>x <nop>
nnoremap <leader>c <nop>
nnoremap <leader>v <nop>
" }}}
" {{{ UPPER RIGHT
nnoremap <leader>u <nop>
nnoremap <leader>p <nop>
nnoremap <leader>o <nop>
nnoremap <leader>i <nop>
" }}}
" {{{ HOME RIGHT
nnoremap <leader>l <nop>
nnoremap <leader>k <nop>
" }}}
" {{{ LOWER RIGHT
nnoremap <leader>/ <nop>
nnoremap <leader>. <nop>
" nnoremap <leader>, <nop> " Commented out because this is the leader key
nnoremap <leader>m <nop>
" }}}
" }}}
"{{{ LEADER NUMBER KEY MAPS - COMMON LOCATIONS
nnoremap <leader>1 :e ~/Dropbox/personal/journal.gpg<CR>
nnoremap <leader>2 :e ~/Dropbox/personal/wiki/index.wiki<CR>
nnoremap <leader>3 :ScratchPreview<CR>
nnoremap <leader>4 <nop>
nnoremap <leader>5 <nop>
nnoremap <leader>6 <nop>
nnoremap <leader>7 <nop>
nnoremap <leader>8 <nop>
nnoremap <leader>9 <nop>
nnoremap <leader>0 :e $MYVIMRC<CR> " My .vimrc file
" }}}
"{{{ FUNCTION KEY MAPS - COMMON ACTIONS
nnoremap <F1> <ESC>:source $MYVIMRC<CR> " Re-source the vimrc file
set pastetoggle=<F2>
nnoremap <F3> <ESC>:2,.w !echo `wc -w` words<CR>
nnoremap <F4> <nop>
nnoremap <F5> <nop>
nnoremap <F6> <nop>
nnoremap <F7> <nop>
nnoremap <F8> <nop>
nnoremap <F9> <nop>
nnoremap <F10> <nop>
nnoremap <F11> <nop>
nnoremap <F12> <nop>
" }}}