forked from pivotalforks/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
284 lines (214 loc) · 6.56 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
"pathogen setup
filetype off "This is to get around a bug
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
"see vim-rails plugin doc [rails.txt]
set nocompatible "Remove compatibility with vi
syntax on "Syntax highlighting
filetype plugin indent on
"ack current word in command mode
function! AckGrep()
let command = "ack ".expand("<cword>")
cexpr system(command)
cw
endfunction
function! AckVisual()
normal gv"xy
let command = "ack ".@x
cexpr system(command)
cw
endfunction
" SHORTCUT KEY MAPPINGS """""""""""""""""""
"prev/next in quickfix file listing (e.g. search results)
map <M-D-Down> :cn<CR>
map <M-D-Up> :cp<CR>
"opt-cmd-arrows [next & previous open files]
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
"Undo/Redo using undo tree with cmd-z/cmd-shift-z
"Doesn't MacVim already have this?
map <D-z> :earlier 1<CR>
map <D-Z> :later 1<CR>
" File tree browser - backslash
map \ :NERDTreeToggle<CR>
" File tree browser showing current file - pipe (shift-backslash)
map \| :NERDTreeFind<CR>
"strip trailing whitespace on save for code files
"cocoa
autocmd BufWritePre *.m,*.h,*.c,*.mm,*.cpp,*.hpp :%s/\s\+$//e
"rails
autocmd BufWritePre *.rb,*.yml,*.js,*.json,*.css,*.less,*.sass,*.html,*.xml,*.erb,*.haml :%s/\s\+$//e
"misc
autocmd BufWritePre *.java,*.php,*.feature :%s/\s\+$//e
"highlight JSON files as javascript
autocmd BufRead,BufNewFile *.json set filetype=javascript
"highlight jasmine_fixture files as HTML
autocmd BufRead,BufNewFile *.jasmine_fixture set filetype=html
"highlight some other filetypes as ruby
au BufRead,BufNewFile *.thor set filetype=ruby
au BufRead,BufNewFile *.god set filetype=ruby
au BufRead,BufNewFile Gemfile* set filetype=ruby
au BufRead,BufNewFile Vagrantfile set filetype=ruby
au BufRead,BufNewFile soloistrc set filetype=ruby
" SETTINGS """"""""""""""""""""""""""""""""
"set t_Co=256
colorscheme vividchalk
colorscheme solarized
set background=dark
"Show whitespace, utf8 thing for trailing whitespace, and show tabs
set list
set listchars=tab:▸\ ,trail:.
"Don't make noise
set visualbell
"Allow the cursor to display plast the line one char
set virtualedit=onemore
"No swap or backup files
set noswapfile
set nobackup
set nowritebackup
"no toolbar
set guioptions-=T
"Search should be case sensitive only to uppercase chars
set ignorecase
set smartcase
"no gui tab bar
set guioptions-=e
"no scrollbars
set guioptions-=rL
"font
set guifont=Inconsolata:h24 "Huge and not always there ...
set guifont=Monaco:h18
"history size
set history=1024
"incremental search
set incsearch
"no wrapping
" set nowrap
"line numbers
set number
"always show statusline
set laststatus=2
"show matching brackets
set showmatch
"tab settings
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
" Rayban & Peter
let mapleader = ","
" FuzzyFinder and switchback commands
map <leader>e :e#<CR>
map <leader>b :FufBuffer<CR>
map <leader>f <Plug>PeepOpen
map <leader><C-N> :FufFile **/<CR>
map <D-e> :FufBuffer<CR>
map <D-N> :FufFile **/<CR>
" search
nmap <leader>s :%s/
vmap <leader>s :s/
" Split screen vertically and move between screens.
map <leader>v :vsp<CR>
map <leader>w ^Ww
map <leader>= ^W=
" Move between horizontally split screens.
map <leader>j ^Wj
map <leader>k ^Wk
" Add new windows towards the right and bottom.
set splitbelow splitright
" AckGrep current word
map <leader>a :call AckGrep()<CR>
" AckVisual current selection
vmap <leader>a :call AckVisual()<CR>
" set question mark to be part of a VIM word. in Ruby it is!
autocmd FileType ruby set iskeyword=@,48-57,_,?,!,192-255
autocmd FileType scss set iskeyword=@,48-57,_,-,?,!,192-255
" Insert ' => '
autocmd FileType ruby imap <Space>=><Space>
" reload .vimrc
map <leader>rv :source ~/.vimrc<CR>
" refresh the FuzzyFinder cache
map <leader>rf :FufRenewCache<CR>
" ctags again with gemhome added
map <leader>t :!/usr/local/bin/ctags -R --exclude=.git --exclude=log * `rvm gemhome`/*<CR>
map <leader>T :!rdoc -f tags -o tags * `rvm gemhome` --exclude=.git --exclude=log
" git blame
map <leader>g :Gblame<CR>
" F7 reformats the whole file and leaves you where you were (unlike gg)
map <silent> <F7> mzgg=G'z :delmarks z<CR>:echo "Reformatted."<CR>
" Write all writeable buffers when changing buffers or losing focus.
autocmd FocusLost * silent! wall
set autowriteall
" Let unsaved buffers exist in the background.
set hidden
" Show typed command prefixes while waiting for operator.
set showcmd
" In insert mode, use Cmd-<CR> to jump to a new line in insert mode, a la
" TextMate.
imap <D-CR> <ESC>o
" Change background color when inserting.
let g:insert_mode_background_color = "#18434E"
" Find unused cucumber steps.
command! CucumberFindUnusedSteps :call CucumberFindUnusedSteps()
function! CucumberFindUnusedSteps()
let olderrorformat = &l:errorformat
try
set errorformat=%m#\ %f:%l
cexpr system('bundle exec cucumber --no-profile --no-color --format usage --dry-run features \| grep "NOT MATCHED BY ANY STEPS" -B1 \| egrep -v "(--\|NOT MATCHED BY ANY STEPS)"')
cwindow
finally
let &l:errorformat = olderrorformat
endtry
endfunction
" Open .vimrc file. (Think Cmd-, [Preferences...] but with Shift.)
map <D-<> :tabedit ~/.vimrc<CR>
" Make command completion act more like bash
set wildmode=list:longest
" Start scrolling when the cursor is within 3 lines of the edge.
set scrolloff=3
" Scroll faster.
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Pad comment delimeters with spaces.
let NERDSpaceDelims = 1
" Comment/uncomment lines.
map <leader>/ <plug>NERDCommenterToggle
" Copy current file path to system pasteboard.
map <silent> <D-C> :let @* = expand("%")<CR>:echo "Copied: ".expand("%")<CR>
" Disable middle mouse button (which is easy to hit by accident).
map <MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>
" Make Y consistent with D and C.
map Y y$
" Don't time out during commands.
set notimeout
" Turn off <F1>
map <F1> <Nop>
imap <F1> <Nop>
" Don't prompt for file changes outside MacVim
set autoread
" Highlight current row.
set cursorline
" Use paste mode when replacing. (Work in progress.)
" vmap <silent> <C-K> :<C-U>call InPasteMode("<Plug>ReplaceVisual")<CR>
" function! InPasteMode(command)
" let oldpaste = &l:paste
" try
" set paste
" execute "normal" "gv".a:command
" finally
" let &l:paste = oldpaste
" endtry
" endfunction
" Command-T
let g:CommandTMaxHeight=20
map <D-N> :CommandTFlush<CR>:CommandT<CR>
" Easy access to the shell.
map <Leader><Leader> :!
" (Keep this at the end.)
" Machine-local vim settings.
silent source ~/.vimrc.local