-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvimrc
406 lines (317 loc) · 12 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
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
" based on http://github.com/jferris/config_files/blob/master/vimrc
" based on Peecode vim-full sample
" based on http://www.pixelbeat.org/settings/.vimrc
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
"Will not work under Teminal.app on Mac OS X - causes certain colors and characters to 'flash'.
set t_Co=256
" Source pathogen. In this case it's in a bundle directory and not the
" Vim autoload directory (and is managed as a git subrepository)
source ~/.vim/bundle/pathogen/autoload/pathogen.vim
" Now call pathogen
silent! call pathogen#infect()
" silent! call pathogen#helptags()
filetype plugin indent on " Turn on file type detection.
runtime macros/matchit.vim " Load the matchit plugin.
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
set visualbell " No beeping.
set nobackup " No automatic backups
set nowritebackup
set directory=$HOME/.vim/tmp//,. " Keep swap files in one location
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set showmode
set incsearch " do incremental searching
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set nowrap " Switch wrap off for everything
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set cpoptions+=$ " Places a dollar sign at the end of the 'to be' changed text.
" Tab completion options
" (only complete to the longest unambiguous match, and show a menu)
set completeopt=longest,menu
set wildmode=list:longest,list:full
set complete=.,t
" case only matters with mixed case expressions
set ignorecase
set smartcase
" Numbers
set number
set numberwidth=5
"mark syntax errors with :signs
let g:syntastic_enable_signs=1
" Don't use Ex mode, use Q for formatting
map Q gq
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Set File type to 'text' for files ending in .txt
autocmd BufNewFile,BufRead *.txt setfiletype text
" Set file type for nginx configs
autocmd BufNewFile,BufRead /etc/nginx/* set ft=nginx
autocmd BufNewFile,BufRead /private/etc/nginx/* set ft=nginx
autocmd BufNewFile,BufRead /usr/local/etc/nginx/* set ft=nginx
" Enable soft-wrapping for text files
autocmd FileType text,markdown,html,xhtml,eruby setlocal wrap linebreak nolist
" Set tab and shitwidth settings for ruby
autocmd FileType ruby setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
" autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Automatically load .vimrc source when saved
autocmd BufWritePost .vimrc source $MYVIMRC
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
if has("folding")
set foldenable
set foldmethod=syntax
set foldlevel=20
set foldnestmax=2
set foldtext=strpart(getline(v:foldstart),0,50).'\ ...\ '.substitute(getline(v:foldend),'^[\ #]*','','g').'\ '
endif
" Always display the status line
set laststatus=2
""""""""""""""""""""""""""""""""""""""""""""""""
" Syntax highlighting
""""""""""""""""""""""""""""""""""""""""""""""""
" syntax enable " Turn on syntax highlighting (compare with syntax on below)
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
syntax on
set incsearch " Highlight matches as you type
set hlsearch " Highlight matches.
endif
if &diff
"I'm only interested in diff colours
syntax off
endif
" Color scheme
colorscheme daring-dark-wsl
highlight NonText guibg=#060606
highlight Folded guibg=#0A0A0A guifg=#9090D0
"syntax highlight shell scripts as per POSIX,
"not the original Bourne shell which very few use
let g:is_posix = 1
"flag problematic whitespace (trailing and spaces before tabs)
"Note you get the same by doing let c_space_errors=1 but
"this rule really applys to everything.
"highlight RedundantSpaces term=standout ctermbg=red guibg=red
"match RedundantSpaces /\s\+$\| \+\ze\t/ "\ze sets end of match so only spaces highlighted
"use :set list! to toggle visible whitespace on/off
set listchars=tab:>-,trail:.,extends:>
" Useful status information at bottom of screen
"set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{fugitive#statusline()}%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P
"set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{fugitive#statusline()}%{exists('*CapsLockStatusline')?CapsLockStatusline():''}%{exists('g:loaded_rvm')?rvm#statusline():''}%=%-16(\ %l,%c-%v\ %)%P
""""""""""""""""""""""""""""""""""""""""""""""""
" Key bindings
""""""""""""""""""""""""""""""""""""""""""""""""
" \ is the leader character
let mapleader = ","
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
"all Enter to be used to create a new blank line and return to normal mode.
"map <CR> O<Esc>j
"map <S-Enter> o<Esc>k
"map toggle vertical split for NERDTree
map <F2> :NERDTreeToggle<CR>
"Map spacebar to buffer explorer.
"nmap <Space> <leader>be
"
"Map spacebar to CommandTBuffer
"nmap <Space> :CommandTBuffer<CR>
nmap <Space> :CtrlPBuffer<CR>
"CommandT command
"noremap <Leader>z :CommandT<CR>
"TComment toggle mapping
noremap <Leader>cc :TComment<CR>
"Textile preview settings and mapping
let g:TextileBrowser="Google Chrome"
noremap <leader>pt :TextilePreview<CR>
"Markdown preview"
noremap <leader>pm :Mm<CR>
"Use CTRL-S for saving, also in Insert mode
"Requires bash$ stty -ixon -ixoff to capture Ctrl-S
noremap <C-s> :update<CR>
cnoremap <C-s> <Esc>:update<CR>
inoremap <C-s> <Esc>:update<CR>
"Map <Esc> to <Esc>`^ which will prevent the curser from moving back a space
"after leaving insert mode.
"inoremap <Esc> <Esc>`^
"Also map the backtick ' - to leave escape mode.
"inoremap ` <Esc>`^
"allow deleting selection without updating the clipboard (yank buffer)
vnoremap x "_x
vnoremap X "_X
"This is necessary to allow pasting from outside vim. It turns off auto stuff.
"You can tell you are in paste mode when the ruler is not visible
"NOTE: This has been set above at F9 - and F2 has been remapped to NERDTree
"toggle.
"set pastetoggle=<F2>
" Tab mappings.
" map <leader>tt :tabnew<cr>
" map <leader>te :tabedit
" map <leader>tc :tabclose<cr>
" map <leader>to :tabonly<cr>
" map <leader>tn :tabnext<cr>
" map <leader>tp :tabprevious<cr>
" map <leader>tf :tabfirst<cr>
" map <leader>tl :tablast<cr>
" map <leader>tm :tabmove
" imap <Tab> <C-N>
" imap <S-Tab> <C-P>
" vmap <Tab> >gv
" vmap <S-Tab> <gv
" nmap <S-Tab> <C-W><C-W>
" Edit the README_FOR_APP (makes :R commands work)
map <Leader>R :e doc/README_FOR_APP<CR>
" Hide search highlighting
map <Leader>h :set invhls <CR>
" Opens an edit command with the path of the currently edited file filled in
" Normal mode: <Leader>e
map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Opens a tab edit command with the path of the currently edited file filled in
" Normal mode: <Leader>t
map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
" Move lines up and down
map <C-J> :m +1 <CR>
map <C-K> :m -2 <CR>
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" Duplicate a selection
" Visual mode: D
vmap D y'>p
" Press Shift+P while in visual mode to replace the selection without
" overwriting the default register
vmap P p :call setreg('"', getreg('0')) <CR>
" For Haml
au! BufRead,BufNewFile *.haml setfiletype haml
" No Help, please
nmap <F1> <Esc>
" Press ^F from insert mode to insert the current file name
imap <C-F> <C-R>=expand("%")<CR>
" Maps autocomplete to tab
imap <Tab> <C-N>
imap <C-L> <Space>=><Space>
" Display extra whitespace
" set list listchars=tab:»·,trail:·
" Use Ack instead of Grep when available
if executable("ack")
set grepprg=ack\ -H\ --nogroup\ --nocolor\ --ignore-dir=tmp\ --ignore-dir=coverage
endif
" Snippets are activated by Shift+Tab
let g:snippetsEmu_key = "<S-Tab>"
" Tags
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
set tags=./tags;
let g:fuf_splitPathMatching=1
fun! TrimWhitespace()
let l:save = winsaveview()
%s/\s\+$//e
call winrestview(l:save)
endfun
command! TrimWhitespace call TrimWhitespace()
" Open URL
" command -bar -nargs=1 OpenURL :!open <args>
" function! OpenURL()
" let s:uri = matchstr(getline("."), '[a-z]*:\\/\\/[^ >,;:]*')
" echo s:uri
" if s:uri != ""
" exec "!open \\"" . s:uri . "\\""
" else
" echo "No URI found in line."
" endif
" endfunction
" map <Leader>w :call OpenURL()<CR>
"Set F9 to toggle line numbers in normal mode
nmap <F9> :set invnumber<CR>
"Set F9 to toggle paste mode in insert mode.
set pastetoggle=<F9>
"Markdown to HTML
nmap <Leader>md :%!/usr/local/bin/Markdown.pl --html4tags<CR>
" Uncomment to use Jamis Buck's file opening plugin
"map <Leader>t :FuzzyFinderTextMate<Enter>
" Controversial...swap colon and semicolon for easier commands
"nnoremap ; :
"nnoremap : ;
"vnoremap ; :
"vnoremap : ;
" Automatic fold settings for specific files. Uncomment to use.
" autocmd FileType ruby setlocal foldmethod=syntax
" autocmd FileType css setlocal foldmethod=indent shiftwidth=2 tabstop=2
" For the MakeGreen plugin and Ruby RSpec. Uncomment to use.
" autocmd BufNewFile,BufRead *_spec.rb compiler rspec
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.crypt = '🔒'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.maxlinenr = '☰'
let g:airline_symbols.maxlinenr = ''
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.spell = 'Ꞩ'
let g:airline_symbols.notexists = '∄'
let g:airline_symbols.whitespace = 'Ξ'
" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
" set vim-airline theme
let g:airline_theme='custom'
" The dark.vim theme override:
"let s:airline_a_normal = [ '#00005f' , '#d7d787' , 17 , 186 ]
"let s:airline_b_normal = [ '#ffffff' , '#444444' , 255 , 238 ]
"let s:airline_c_normal = [ '#9cffd3' , '#202020' , 85 , 234 ]
"let g:airline#themes#dark#palette.normal = airline#themes#generate_color_map(s:airline_a_normal, s:airline_b_normal, s:airline_c_normal)
" Local config
if filereadable(".vimrc.local")
source .vimrc.local
endif