-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
299 lines (237 loc) · 8.04 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
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
"COLOR SCHEMES
"=========================================================
Plugin 'altercation/vim-colors-solarized'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
" Rails
Plugin 'tpope/vim-rails'
" Rspec
Plugin 'thoughtbot/vim-rspec'
" file tree
Plugin 'scrooloose/nerdtree'
" file tree and tabs interaction
Plugin 'jistr/vim-nerdtree-tabs'
" commenting
Plugin 'scrooloose/nerdcommenter'
" fuzzy file open
Plugin 'kien/ctrlp.vim'
" popup completion menu
Plugin 'AutoComplPop'
" tags list navigation
Plugin 'taglist.vim'
" git integration
Plugin 'tpope/vim-fugitive'
" syntax checking on save
Plugin 'scrooloose/syntastic'
" TextMate-style snippets
Plugin 'msanders/snipmate.vim'
" manipulation of surraunding parens, quotes, etc.
Plugin 'tpope/vim-surround'
" vertical alignment tool
Plugin 'tsaleh/vim-align'
" 'ag' searching integration
Plugin 'rking/ag.vim'
" buffers
Plugin 'fholgado/minibufexpl.vim'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'pangloss/vim-javascript'
Plugin 'Rename.vim'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'vim-ruby/vim-ruby'
Plugin 'vim-scripts/ctags.vim.git'
" All of your Plugins must be added before the following line
call vundle#end() " required
"Color Scheme Config
"---------------------------------------------------------
colorscheme solarized
set background=dark
set guifont=Monaco:h13
filetype plugin indent on " required
:au FocusLost * silent! wa
:set autowrite
" Leader
let mapleader = ","
set backspace=2 " Backspace deletes like most programs in insert mode
set nobackup
set nowritebackup
set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
set history=50
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set laststatus=2 " Always display the status line
set autowrite " Automatically :write before running commands
" 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
endif
" Comment/uncomment lines
map <leader>/ <plug>NERDCommenterToggle
map <D-/> <plug>NERDCommenterToggle
imap <D-/> <Esc><plug>NERDCommenterToggle i
" kj - The intuitive way to get out of insert mode
imap kj <Esc>
" Make Y consistent with D and C
map Y y$
" Search
nmap <leader>s :%s/
vmap <leader>s :s/
" Split screen
map <leader>v :vsp<CR>
" Open .vimrc file in new tab. Think Command + , [Preferences...] but with Shift.
map <D-<> :tabedit ~/.vimrc<CR>
" Reload .vimrc
map <leader>rv :source ~/.vimrc<CR>
" Auto-indent whole file
nmap <leader>= gg=G``
map <silent> <F7> gg=G``:echo "Reformatted."<CR>
" Jump to a new line in insert mode
imap <D-CR> <Esc>o
" Fast scrolling
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" File tree browser
map \ :NERDTreeToggle<CR>
" File tree browser showing current file - pipe (shift-backslash)
map \| :NERDTreeFind<CR>
" Previous/next quickfix file listings (e.g. search results)
map <M-D-Down> :cn<CR>
map <M-D-Up> :cp<CR>
" Previous/next buffers
map <M-D-Left> :bp<CR>
map <M-D-Right> :bn<CR>
"indent/unindent visual mode selection with tab/shift+tab
vmap <tab> >gv
vmap <s-tab> <gv
map <Leader>f :CtrlP<cr>
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile Appraisals set filetype=ruby
autocmd BufRead,BufNewFile *.md set filetype=markdown
" Enable spellchecking for Markdown
autocmd FileType markdown setlocal spell
kj
" Automatically wrap at 72 characters and spell check git commit messages
autocmd FileType gitcommit setlocal textwidth=72
autocmd FileType gitcommit setlocal spell
" Allow stylesheets to autocomplete hyphenated words
autocmd FileType css,scss,sass setlocal iskeyword+=-
augroup END
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set shiftround
set expandtab
autocmd FileType javascript setlocal expandtab shiftwidth=2 softtabstop=2
autocmd FileType html setlocal expandtab shiftwidth=2 softtabstop=2
" Display extra whitespace
set list listchars=tab:»·,trail:·,nbsp:·
" CTRLP
"-------------------------------------------------
map <leader>f :CtrlP<CR>
imap <leader>f <ESC>:CtrlP<CR>
let g:ctrlp_custom_ignore = '\v/vendor|/bin|/node_modules|/public/assets|/log'
let g:ctrlp_cmd= 'CtrlP'
let g:ctrlp_show_hidden = 0
noremap <D-r> :CtrlPTag<CR>
"Silver Searcher
"-------------------------------------------------
ca Ag Ag!
"if executable('ag')
"" Use Ag over Grep
""===================
"set grepprg=ag\ --nogroup\ --nocolor
"" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
""---------------------------------------------------------------------
"let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
"" ag is fast enough that CtrlP doesn't need to cache
"let g:ctrlp_use_caching = 1
"endif
" Make it obvious where 80 characters is
set textwidth=80
set colorcolumn=+1
" Numbers
set number
set numberwidth=5
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
inoremap <S-Tab> <c-n>
" Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
" Index ctags from any project, including those outside Rails
map <Leader>ct :!ctags -R .<CR>
" Switch between the last two files
nnoremap <leader><leader> <c-^>
" Get off my lawn
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
" vim-rspec mappings
nnoremap <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <Leader>s :call RunNearestSpec()<CR>
nnoremap <Leader>l :call RunLastSpec()<CR>
" Run commands that require an interactive shell
nnoremap <Leader>r :RunInInteractiveShell<space>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
" Open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" configure syntastic syntax checking to check on open as well as save
let g:syntastic_check_on_open=1
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
" Set spellfile to location that is guaranteed to exist, can be symlinked to
" Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm.
set spellfile=$HOME/.vim-spell-en.utf-8.add
" Autocomplete with dictionary words when spell check is on
set complete+=kspell
" Always use vertical diffs
set diffopt+=vertical
" Local config
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif
"CUSTOM FUNCTIONS
"======================================================================
"Autosave on lost focus
"-----------------------
function! FocusLost_SaveFiles()
exe ":au FocusLost" expand("%") ":wa"
endfunction
:call FocusLost_SaveFiles()