-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
341 lines (260 loc) · 8.58 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
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
" For the below config, see here:
" http://amix.dk/vim/vimrc.html
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=1700
" Enable filetype plugins
filetype on
filetype plugin on
filetype indent on
" Add Pathogen support for management of assets
execute pathogen#infect()
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on the WiLd menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
"Always show current position
set ruler
" Height of the command bar
set cmdheight=2
" Configure backspace so it acts as it should act
set backspace=2
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
set t_Co=256
highlight Normal ctermfg=grey ctermbg=black
colorscheme mustang
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions+=e
set t_Co=256
set guitablabel=%M\ %t
set guioptions+=Lrb
set guioptions-=Lrb
endif
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
" Use UNIX as the standard file type
set ffs=unix,dos,mac
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
set softtabstop=4
set cindent
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
"Bubble single lines (kicks butt)
""http://vimcasts.org/episodes/bubbling-text/
nmap <C-j> ddp
nmap <C-k> ddkP
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Format the status line
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
" Set region to British English
set spelllang=en_gb
" Set spellchecking in git commit messages
au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
" Add spellchecking by default
map <F5> :setlocal spell! spelllang=en_gb<CR>
" Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Temporary Files
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set backupdir=~/.vim/tmpdir
set directory=~/.vim/tmpdir
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
if &paste
return 'PASTE MODE '
en
return ''
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Previous (non-website) config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
set number
set scrolloff=3
"Set undo'ing
set undodir=~/.vim/undodir
set undofile
set undolevels=1000
set undoreload=10000
"copy and paste to x
map ppp "*p
map yyy "*y
"Speed up buffer switching
map <C-Up> <C-W>k
map <C-Down> <C-W>j
map <C-Left> <C-W>h
map <C-Right> <C-W>l
map <Tab> :tabnext <Enter>
map <S-Tab> :tabprev <CR>
"Speed up buffer resizing
map + <C-W>+
map - <C-W>-
"Add reviewed by tag
:map <F7> oReviewed-by: Gordon Thomson <[email protected]><Esc>
"Add tested by tag - 1.8
:map <F8> oTested-by: Gordon Thomson <[email protected]> [Ubuntu 13.10]<Esc>
"Add signed off by tag
:map <F9> oSigned-off-by: Gordon Thomson <[email protected]><Esc>
"Shortcut to rapidly toggle `set list` which shows hidden chars
nmap <leader>l :set list!<CR>
"Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:?\ ,eol:¬
"Enable mouse usage
set ttymouse=xterm
set mouse=r
"Set PHP file indentation characteristics
au BufRead,BufNewFile *.html,*.php set filetype=php
autocmd FileType php set expandtab
autocmd FileType php set tabstop=4
autocmd FileType php set shiftwidth=4
autocmd FileType php set autoindent
autocmd FileType php set smartindent
" The line below adds closing braces when opening braces are typed, and moves the cursor to the next line (with indent).
"autocmd FileType php inoremap { {<CR>}<up><end><CR>
"Ruby-specific stuff here
autocmd BufNewFile,BufRead *.feature,*.story set filetype=cucumber
au BufRead,BufNewFile *.rhtml,*.rb set filetype=ruby
autocmd FileType ruby set tabstop=2
autocmd FileType ruby set shiftwidth=2
autocmd FileType ruby set expandtab
autocmd FileType ruby set softtabstop=2
autocmd FileType cucumber set tabstop=2
autocmd FileType cucumber set shiftwidth=2
autocmd FileType cucumber set expandtab
autocmd FileType cucumber set softtabstop=2
"Git commit messages
autocmd FileType gitcommit call setpos('.', [0, 1, 1, 0])
" Highlight extra whitespace in files
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+$/
"Strip Trailing Whitespace
function! <SID>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
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
"Smarty support
au BufRead,BufNewFile *.tpl set filetype=smarty
"ASP formatting
autocmd BufNewFile,BufRead *.asp set ft=aspvbs
" Blade support
autocmd BufNewFile,BufRead *.blade.php set ft=blade.html.php
"Abbreviations
ab US United States
ab helpers Helpers
ab dh displayHelpers::debugData(
ab Heleprs Helpers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Shell Interaction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufEnter * let &titlestring = ' ' . expand("%:t")
set title
" Add spellchecking by default
map <F3> :w !php -l<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Add JS handling functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let javascript_enable_domhtmlcss=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Add binding for testing
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap ,t :!phpunit<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Add binding for syntax checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap ,. :w !php -l<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Powerline Config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
set linespace=0
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Prompt for sudo when saving privileged files
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command W :execute ':silent w !sudo tee % > /dev/null' | :edit!