-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvimrc.symlink
executable file
·424 lines (340 loc) · 16.7 KB
/
vimrc.symlink
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
" ----------------------------------------------------------------------------
" General
" ----------------------------------------------------------------------------
set nocompatible " Don't sacrifice anything for Vi compatibility
set history=1000 " Keep some stuff in the history
set ffs=unix,dos,mac " Support these files
set isk+=_,$,@,%,#,- " None word dividers
set viminfo='1000,f1,:100,@100,/20
set modeline " Make sure modeline support is enabled
set autoread " Reload the files if they changed on disk
set tabpagemax=50 " Open 50 tabs max
set encoding=utf-8 " Always use UTF-8 by default
set timeoutlen=500 " Timeout between key command combos
" Pathogen
source ~/.vim/bundle/pathogen/autoload/pathogen.vim
call pathogen#runtime_append_all_bundles()
" ----------------------------------------------------------------------------
" Backups
" ----------------------------------------------------------------------------
set nobackup " do not keep backups after close
set nowritebackup " do not keep a backup while working
set noswapfile " don't keep swp files either
set backupdir=$HOME/.vim/backup " store backups under ~/.vim/backup
set backupcopy=yes " keep attributes of original file
set backupskip=/tmp/*,/private/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
set directory=~/.vim/swap,~/tmp,.
" ----------------------------------------------------------------------------
" UI
" ----------------------------------------------------------------------------
set hidden " Handle multiple buffers better
set ruler " Show cursor position
set showcmd " Display incomplete commands
set showmode " Display the mode you're in
set nolazyredraw " Don't redraw while executing macros
set number " Show line numbers
set wildmenu " Enhanced command line completion: like a shell
set wildmode=list:longest
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=_build " Sphinx build dir
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.pyc " Python byte code
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store
set wildignore+=*CACHE
set cmdheight=2 " Command line height
set backspace=indent,eol,start " Intuitive backspacing
set whichwrap+=<,>,h,l,[,] " Backspace and cursor keys wrap to
set shortmess=aoOtAI " Shorten messages
set report=0 " Tell us about changes
set nostartofline " Don't jump to start of line when scrolling
set scrolloff=5 " Show 5 lines of context around the cursor
" ----------------------------------------------------------------------------
" Visual Cues
" ----------------------------------------------------------------------------
set visualbell " No beeping
set title " Set the terminal's title
set cursorline " Cursor line indicator
set shellslash " Use forward slashes everwhere
set mousehide " Hide the mouse pointer while typing
set laststatus=2 " Always show status line
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y
set statusline+=\ %{exists('fugitive')?fugitive#statusline():''}
set statusline+=%=%-16(\ %l,%c-%v\ %)%P
set list " Show whitespace chars
set listchars=tab:»\ ,eol:¬,trail:·
set showmatch " Show matching brackets
set hlsearch " Highlight search matches
set incsearch " Highlight matches as you type
set ignorecase " Case-insensitive searching
set smartcase " ...but case-sensitive if expression contains a capital letter
set wrapscan " Set the search scan to wrap around the file
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
" ----------------------------------------------------------------------------
" Text Formatting
" ----------------------------------------------------------------------------
set autoindent " automatic indent new lines
set smartindent
set nowrap " Turn off line wrapping
set softtabstop=4 " Global soft tab width
set shiftwidth=4 " Global whitespace shift width
set tabstop=4 " Global tab width
set expandtab " Expand tabs to spaces
set nosmarttab
set formatoptions+=n " Support for numbered/bullet lists
set textwidth=79 " Wrap at 79 chars by default
set virtualedit=block " Allow virtual edit in visual block
set nojoinspaces " Do not insert 2 spaces after a '.', '?', or '!'
" ----------------------------------------------------------------------------
" Mappings
" ----------------------------------------------------------------------------
let mapleader="," " Lead with ,
let g:mapleader="," " ...and again
let maplocalleader="\\" " For certain plugins that use localleader
" Editing .vimrc
nmap <Leader>v :e $MYVIMRC<CR>
" Remap ; to :
nnoremap ; :
" Quicker shell commands
nmap ! :!
" Fix Y so it behaves like D
nnoremap Y y$
" Remap <f1> to <esc> to accommodate my fat-fingering ways
imap <f1> <esc>
vmap <f1> <esc>
" Do not attempt to display manual
nnoremap K <nop>
" Sane movement with wrap turned on
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
" inoremap <Down> <C-o>gj
" inoremap <Up> <C-o>gk
" Unimpaired -- bubble single and multiple lines
nmap <C-Up> [e
nmap <C-Down> ]e
vmap <C-Up> [egv
vmap <C-Down> ]egv
" Press space bar to turn off search highlighting and clear any message displayed
nnoremap <silent> <Space> :nohl<Bar>:echo<CR>
" Substitute
nnoremap <Leader>s :%s//g<left><left>
" Append modeline after last line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX files.
function! AppendModeline()
let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d :",
\ &tabstop, &shiftwidth, &textwidth)
let l:modeline = substitute(&commentstring, "%s", l:modeline, "")
silent! call append(line("$"), l:modeline)
endfunction
nnoremap <silent> <Leader>ml :call AppendModeline()<CR>
" Uppercase
nnoremap <C-u> gUiw
inoremap <C-u> <esc>gUiwea
" Reflow paragraph with Q in normal and visual mode
nnoremap Q gqap
vnoremap Q gq
" Retab a source file
nmap <Leader>rr :retab!<CR>
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>mm mmHmt:%s/<C-V><CR>//ge<CR>'tzt'm
" Toggle whitespace characters
nmap <Leader>l :set list!<CR>
" 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
silent! call cursor(l, c)
endfunction
nnoremap <silent> <Leader>W :call <SID>StripTrailingWhitespaces()<CR>
" Make the directory that contains the file in the current buffer.
" This is useful when you edit a file in a directory that doesn't
" (yet) exist
nmap <Leader>md :!mkdir -p %:p:h
" 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>
" Inserts the path of the currently edited file into a command
" Command mode: Ctrl+P
cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
" ----------------------------------------------------------------------------
" Autocommands
" ----------------------------------------------------------------------------
filetype on
filetype plugin on
filetype indent on
filetype plugin indent on
if has("autocmd")
" Remember last location in a file
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" Save on lose focus
au FocusLost * :wa
" Source .vimrc on save
au BufWritePost .vimrc source $MYVIMRC
" Keep splits sized properly
au VimResized * exe "normal! \<cw>="
" Syntax of these languages is fussy over tabs vs spaces
au FileType make setlocal ts=4 sts=4 sw=4 noet
au FileType yaml,haml setlocal ts=2 sts=2 sw=2 et
" Whitespace based on house-style (arbitrary)
au FileType html setlocal ts=4 sts=4 sw=4 noet
au FileType xhtml setlocal ts=4 sts=4 sw=4 et
au FileType css setlocal ts=4 sts=4 sw=4 noet
au FileType ruby setlocal ts=2 sts=2 sw=2 et
au FileType sass setlocal ts=2 sts=2 sw=2 et
au FileType less setlocal ts=4 sts=4 sw=4 noet
au FileType javascript setlocal ts=4 sts=4 sw=4 noet
au FileType xml setlocal ts=4 sts=4 sw=4 et
"" HTML
au FileType html,xhtml setlocal fo+=tl " for HTML, generally format text, but if a long line has been created leave it alone when editing:
au BufNewFile,BufRead *.{jsp,jspf} setlocal ft=jsp.html " set .jsp files to edit like HTML
"" CSS
au BufNewFile,BufRead *.scss setlocal ft=scss.css " Get CSS snippets in SCSS files
au BufNewFile,BufRead *.less setlocal ft=less.css " Get CSS snippets in LESS files
"" JavaScript
au BufNewFile,BufRead *.{json,htc} setlocal ft=javascript " Syntax highlighting for JSON files
"" Python
au FileType python setlocal ts=4 sts=4 sw=4 et " make python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
au FileType python match OverLength /\%79v.\+/
"" PHP
au BufNewFile,BufRead *.ctp setlocal ft=php " set .ctp files to edit like php for cakePHP
"" Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} setlocal ft=ruby
"" Markdown -- markdown, md, mk, mkd, pdk, pandoc, and text are markdown and define buffer-local preview
au FileType markdown,md,mk,mkd,pdk,pandoc,text nnoremap <buffer> <localleader>1 yypVr=
au FileType markdown,md,mk,mkd,pdk,pandoc,text nnoremap <buffer> <localleader>2 yypVr-
"" reStructuredText
au FileType rst nnoremap <buffer> <localleader>1 yypVr=
au FileType rst nnoremap <buffer> <localleader>2 yypVr-
au FileType rst nnoremap <buffer> <localleader>3 yypVr~
au FileType rst nnoremap <buffer> <localleader>4 yypVr`
"" Open help files in a vertical split
au BufWinEnter *.txt if &ft == 'help' | wincmd L | endif
endif
" ----------------------------------------------------------------------------
" GUI Settings
" ----------------------------------------------------------------------------
set guioptions-=T " Hide toolbar.
set guioptions-=l " Don't show left scrollbar
set guioptions-=L " Don't show left scrollbar
set guioptions-=r " Don't show right scrollbar
set guioptions-=R " Don't show right scrollbar
set guioptions+=aA " Autoselect.
set guioptions+=c " Use console dialogs
set guifont=Inconsolata:h14 " Font family and font size.
set antialias " MacVim: smooth fonts.
if has('mouse')
set mouse=a " Enable mouse usage (all modes) in terminal
endif
if has("gui_macvim")
" MacVIM shift+arrow-keys behavior (required in .vimrc)
let macvim_hig_shift_movement = 1
" Command-Shift-F for Ack
map <D-F> :Ack!<space>
" Command-/ to toggle comments
nmap <D-/> <Plug>CommentaryLine
" Command-][ to increase/decrease indentation
vmap <D-]> >gv
vmap <D-[> <gv
endif
set background=dark
colorscheme badwolf " Default terminal color scheme
syntax enable " Turn on syntax highlighting
set synmaxcol=2048 " Syntax coloring too-long lines is slow
" ----------------------------------------------------------------------------
" Plugins
" ----------------------------------------------------------------------------
runtime macros/matchit.vim " Load the matchit plugin
" abolish git://github.com/tpope/vim-abolish.git
" ack git://github.com/mileszs/ack.vim.git
" bufexplorer git://github.com/vim-scripts/bufexplorer.zip.git
map <silent> <Leader>b :BufExplorer<CR>
map <silent> <Space>b :BufExplorer<CR>
let g:bufExplorerSortBy='extension'
" bufkill git://github.com/vim-scripts/bufkill.vim.git
" ctrlp git://github.com/kien/ctrlp.vim.git
"let g:ctrlp_map = '<C-Space>'
map <C-Space> :CtrlP<CR>
map <D-t> :CtrlP<CR>
imap <D-t> <Esc>:CtrlP<CR>
nmap <Leader>f :ClearCtrlPCache<CR>
let g:ctrlp_working_path_mode = 0
" coffeescript git://github.com/kchmck/vim-coffee-script.git
" solarized git://github.com/altercation/vim-colors-solarized.git
if has('gui_running')
let g:solarized_hitrail=1
else
set background=light
let g:solarized_termcolors=16
endif
" colorschemes git://github.com/flazz/vim-colorschemes.git
" commentary git://github.com/tpope/vim-commentary.git
xmap \ <Plug>Commentary
nmap \ <Plug>Commentary
nmap \\ <Plug>CommentaryLine
nmap \u <Plug>CommentaryUndo
" css-color git://github.com/skammer/vim-css-color.git
" delimitmate git://github.com/Raimondi/delimitMate.git
" endwise git://github.com/tpope/vim-endwise.git
" extradite git://github.com/int3/vim-extradite.git
" fugitive git://github.com/tpope/vim-fugitive.git
" gist git://github.com/mattn/gist-vim.git
" git git://github.com/tpope/vim-git.git
" greplace git://github.com/vim-scripts/greplace.vim.git
" haml git://github.com/tpope/vim-haml.git
" html5 git://github.com/othree/html5.vim.git
" indent-object git://github.com/michaeljsmith/vim-indent-object.git
"ai,ii work best for Python, aI,II work best for Ruby/C/Perl
" javascript git://github.com/pangloss/vim-javascript.git
" jquery git://github.com/vim-scripts/jQuery.git
" jshint git://github.com/sleistner/vim-jshint.git
nmap <Leader>j :JSHintToggle<CR>
" liquid git://github.com/tpope/vim-liquid.git
" nerdtree git://github.com/scrooloose/nerdtree.git
nmap <Space>d :NERDTreeToggle<CR>
nmap <Leader>d :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.rbc$', '\~$']
let NERDTreeDirArrows=0
" pandoc git://github.com/vim-pandoc/vim-pandoc.git
let g:pandoc_no_folding = 1
let g:pandoc_no_empty_implicits = 1
let g:pandoc_no_spans = 1
" ragtag git://github.com/tpope/vim-ragtag.git
" rake git://github.com/tpope/vim-rake.git
" repeat git://github.com/tpope/vim-repeat.git
" rooter git://github.com/airblade/vim-rooter.git
" snipmate git://github.com/garbas/vim-snipmate.git
let g:snips_author = 'Stephen Tudor'
"let g:snips_trigger_key = '<F12>'
" snipmate-snippets git://github.com/honza/snipmate-snippets.git
" sparkup git://github.com/kogakure/vim-sparkup.git
let g:sparkupNextMapping = '<c-;>'
" speeddating git://github.com/tpope/vim-speeddating.git
" surround git://github.com/tpope/vim-surround.git
" tabular git://github.com/godlygeek/tabular.git
" tagbar git://github.com/majutsushi/tagbar.git
nmap <Leader>t :TagbarToggle<CR>
nmap <Space>t :TagbarToggle<CR>
let g:tagbar_sort = 0
let g:tagbar_ctags_bin = "/usr/local/bin/ctags"
" unimpaired git://github.com/tpope/vim-unimpaired.git
" ----------------------------------------------------------------------------
" Include user's local vim config
" ----------------------------------------------------------------------------
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif