-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
194 lines (147 loc) · 4.89 KB
/
Copy pathvimrc
File metadata and controls
194 lines (147 loc) · 4.89 KB
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
call pathogen#infect()
""""""""""""""""""""""
" Basic configuration
"
set nocp " Disable vi compatibility, for vim-specific awesomeness
set expandtab " Expand tabs to spaces
set tabstop=2
set bs=2 " Fix backspace key to work under screen
set shiftwidth=2
set number " Enable line numbering
set autoindent " When you press enter you stay at the current indent
set wildmode=longest,list " Better tab completion for :e and friends
set wildignore=*.rbc,.git,*.o,*.gem
set history=100 " Default is 20, not enough.
set ls=2 " Always display a status line
set colorcolumn=80 " Vertical bar at 80 chars
set visualbell " Use visual bell instead of beeping.
set shortmess=atI " short info tokens, short command line messages, no intro.
set modelines=0 " Disable modelines; not used, risk of security exploits.
set encoding=utf-8 " Default to Unicode/UTF-8 rather than latin1
set ttyfast " Terminals are plenty fast these days.
set winwidth=81 " Ideal minimum window width of 80 chars
set gfn=Monofur:h14
syntax on
filetype plugin indent on
" Mouse is useful for scrolling and selection in some cases
if has("mouse")
set mouse=a
set mousehide
endif
" Store temporary files in a central spot
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" Use ack for grepping
set grepprg=ack
set grepformat=%f:%l:%m
" These leaders work better with Colemak
let mapleader = ";"
let maplocalleader = ","
""""""""""""""""
" PRETTY COLORS
"
if has("gui_running")
set guioptions=egmrt
endif
set t_Co=256
set background=light
colorscheme solarized
call togglebg#map("<F3>")
"""""""""""""""""""""""
" GENERIC KEY BINDINGS
"
" Disable help key coz I mash it when I try to hit Esc
map <F1> <Esc>
imap <F1> <Esc>
" Expands to directory of current file
cnoremap %% <C-R>=expand('%:h').'/'<cr>
" Bind tab to shift between buffers
nmap <tab> :bn<cr>
nmap <s-tab> :bp<cr>
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
" Strip trailing whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Unbind the cursor keys in insert, normal and visual modes.
for prefix in ['i', 'n', 'v']
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
exe prefix . "noremap " . key . " <Nop>"
endfor
endfor
"""""""
" TMUX
"
" Requires tslime.vim
map <leader>s :w\|:call Send_to_Tmux("!!\n")<CR>
"""""""
" RUBY
"
vmap <F2> !format_hash.rb<CR>
vmap <F4> !format_cucumber_table.rb<CR>
" Comment/uncomment ruby code
vmap o :s/^/# /<CR>
vmap i :s/^# //<CR>
" Convert old style ruby hashes to new style
vmap ;h :s/:\(\w*\)\s*=> /\1: /g<CR>
" Rails specific
map <leader>gr :topleft :split config/routes.rb<cr>
map <leader>gg :topleft 100 :split Gemfile<cr>
function! PromoteToLet()
:normal! dd
" :exec '?^\s*it\>'
:normal! P
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
:normal ==
endfunction
:command! PromoteToLet :call PromoteToLet()
:map <leader>p :PromoteToLet<cr>
""""""""""
" CLOJURE
"
let vimfiles=$HOME . "/.vim"
let sep=":"
let vimclojureRoot = vimfiles."/bundle/vimclojure-2.2.0"
let vimclojure#ParenRainbow = 1
let vimclojure#WantNailgun = 0
let classpath = join( [".", "src", "src/main/clojure", "src/main/resources", "test", "src/test/clojure", "src/test/resources", "classes", "target/classes", "lib/*", "lib/dev/*", "bin", vimfiles."/lib/*" ], sep)
"""""""""""
" LILYPOND
"
set runtimepath+=/Applications/LilyPond.app/Contents/Resources/share/lilypond/current/vim
"""""""""""""""""""""""""""""
" HIGHLIGHTING AND FILE TYPES
"
" Highlight trailing whitespace etc
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen
match ExtraWhitespace /\s\+\%#\@<!$/
augroup vimrcEx
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
"Auto reload this file when editing it
au! BufWritePost .vimrc source %
"Add rails filetype to all ruby files, need to find a way to limit to just rails files maybe
au BufRead,BufNewFile *.rb set filetype=ruby.rails.rspec
au BufRead,BufNewFile Isolate set filetype=ruby
au BufRead,BufNewFile config.ru set filetype=ruby
" Override default modula2 detection, these files are markdown
au BufNewFile,BufRead *.md set filetype=markdown
" C style for ruby codes
au FileType c setl ts=4 sw=4 noexpandtab
" Exit insert mode when Vim loses focus.
" A bug prevents this from working: autocmd FocusLost * stopinsert
" See http://stackoverflow.com/questions/2968548
autocmd! FocusLost * call feedkeys("\<C-\>\<C-n>")
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END