This repository has been archived by the owner on Nov 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathvimrc
248 lines (192 loc) · 5.62 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
"pathogen setup
filetype off
call pathogen#helptags()
call pathogen#runtime_append_all_bundles()
"see vim-rails plugin doc [rails.txt]
set nocompatible
syntax on
filetype plugin indent on
" SHORTCUT KEY MAPPINGS """""""""""""""""""
" shift + arrow keys to resize window
nnoremap <S-Up> <C-W>+
nnoremap <S-Down> <C-W>-
nnoremap <S-Left> <C-W><
nnoremap <S-Right> <C-W>>
"Gundo with F5
nnoremap <F5> :GundoToggle<CR>
"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
"rake spec in a split conque term
map <M-C-D-R> :ConqueTermSplit rake spec<CR>
"bundle exec cucumber in a split conque term
map <M-C-D-C> :ConqueTermSplit bundle exec cucumber<CR>
"rake in a split conque term
map <D-R> :ConqueTermSplit rake<CR>
"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
map <D-z> :earlier 1<CR>
map <D-Z> :later 1<CR>
"file tree browser - backslash
map \ :NERDTreeToggle<CR>
"comment/uncomment visual selection with cmd+/
vmap <D-/> <plug>NERDCommenterToggle
"comment/uncomment current line with cmd+/
nmap <D-/> <plug>NERDCommenterToggle
"strip trailing whitespace on save for code files
"cocoa
autocmd BufWritePre *.m,*.h,*.c,*.mm,*.cpp,*.hpp,*.feature :%s/\s\+$//e
"rails
autocmd BufWritePre *.rb,*.yml,*.js,*.css,*.less,*.sass,*.html,*.xml,*.erb,*.haml :%s/\s\+$//e
"misc
autocmd BufWritePre *.java,*.php :%s/\s\+$//e
" SETTINGS """"""""""""""""""""""""""""""""
if has("gui_macvim")
set t_Co=256
colorscheme vividchalk
endif
"Minibuf tab colors - must be set after colorscheme
"Changed + Hidden buffers
hi MBEChanged guibg=darkred ctermbg=darkred guifg=red ctermfg=red
"Changed + Visible buffers
hi MBEVisibleChanged guifg=darkred ctermfg=darkred
"Show whitespace, fullstops for trailing whitespace
set list
set listchars=trail:.
"Keep backup files somewhere else
set backupdir=~/.vim-tmp,~/tmp,/var/tmp,/tmp
"No swapfiles
set noswapfile
"no toolbar
set guioptions=-T
"no gui tab bar
set guioptions-=e
"no scrollbars
set guioptions-=rL
"font
set guifont=Inconsolata:h24
"set guifont=Atari\ Classic\ Chunky:h16
"history size
set history=1024
"incremental search
set incsearch
"no wrapping
set wrap!
"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
set scrolloff=3
" Rayban & Peter
let mapleader = ","
" FuzzyFinder and switchback commands
map <leader>e :e#<CR>
map <leader>b :FufBuffer<CR>
map <leader>f :FufFile<CR>
map <leader><C-N> :FufFile **/<CR>
map <D-e> :FufBuffer<CR>
map <D-N> :FufFile **/<CR>
" search
map <leader>s :%s/
" Split screen vertically and move between screens.
map <leader>v :vsp<CR>
map <leader>w <C-W>w
map <leader>h <C-W>s
map <leader>= <C-W>=
" Move between horizontally split screens.
map <leader>j <C-W>j
map <leader>k <C-W>k
" 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 isk=@,48-57,_,?,!,192-255
" Insert ' => '
autocmd FileType ruby imap <C-l> <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>
" Run a test tool with the current file and line number
" The test tool is run in the last Terminal window
function! RunTestTool(tool_cmd)
let dir = system('pwd')
let cuke_cmd = a:tool_cmd." ".expand("%").":".line(".")
let applescript = "osascript -e '".'tell application "Terminal"'
let applescript = applescript."\n"
let applescript = applescript.'do script "cd '.dir.'" in last window'
let applescript = applescript."\n"
let applescript = applescript.'do script "'.cuke_cmd.'" in last window'
let applescript = applescript."\n"
let applescript = applescript.'end tell'."'"
let foo = system(applescript)
endfunction
" If the file ends with _spec.rb, RunTestTool with rspec
" If the file ends with .feature, RunTestTool with cuke
command! RunTest :call RunTest()
function! RunTest()
let filename = expand("%")
if filename =~ '_spec\.rb$'
call RunTestTool("be rspec")
endif
if filename =~ '\.feature$'
call RunTestTool("cuke")
endif
endfunction
" Run test at cursor
map <leader>R :RunTest<CR>
" F7 reformats the whole file and leaves you where you were (unlike gg)
map <F7> mzgg=G'z :delmarks z<CR>
" Turn on Ruby folding but unfold when you open a new file because it's
" annoying
"let ruby_fold=1
"au BufAdd *.rb foldopen!
" 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
set ruler " cursor position
" more search options
set hlsearch
set smartcase
" Open reposh
map <C-G> :!reposh<CR>
map <C-A> :!gitx<CR><CR>
" In insert mode, use Cmd-<CR> to jump to a new line in insert mode, a la
" TextMate.
imap <D-CR> <ESC>o
" Find tag
map <D-˜> :FufTag<CR>
" Change background color when inserting.
let g:insert_mode_background_color = "#333333"