-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.vimrc
283 lines (219 loc) · 7.15 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
set nocompatible
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
runtime! autoload/pathogen.vim
if exists('g:loaded_pathogen')
call pathogen#runtime_prepend_subdirectories(expand('~/.vim/bundle'))
end
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
syntax on
filetype plugin indent on
filetype plugin on
set completeopt=menuone,preview,longest
"set completeopt=menuone,preview
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
set complete-=i
" Omni completion settings
"set ofu=syntaxcomplete#Complete
"let g:rubycomplete_buffer_loading = 0
"let g:rubycomplete_classes_in_global = 1
" enable 256 colors in GNOME terminal (for my Ubuntu VM)
if $COLORTERM == 'gnome-terminal'
set t_Co=256
colorscheme Tomorrow-Night-Bright
endif
" completing Rails hangs a lot
let g:rubycomplete_rails = 1
" set supported JS libraries
let g:used_javascript_libs = 'underscore,angularjs,jquery,requirejs'
" syntastic
let g:syntastic_enable_signs=1
let bash_is_sh=1
set cinoptions=:0,(s,u0,U1,g0,t0
set modelines=5
set tags=tags;/
set laststatus=2
" default:
" set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" highlihgt the file name
hi User1 term=bold,reverse cterm=bold ctermfg=4 ctermbg=2 gui=bold guifg=Blue guibg=#44aa00
"set cuc
"set cul
set number
"fixdel
" prevent vim from adding that stupid empty line at the end of every file
set noeol
set binary
"Ignore these files when completing names and in Explorer
set wildignore=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif
"hi SpellErrors guibg=red guifg=black ctermbg=red ctermfg=black
" enable showmmarks
let g:showmarks_enable = 1
hi! link ShowMarksHLl LineNr
hi! link ShowMarksHLu LineNr
hi! link ShowMarksHLo LineNr
hi! link ShowMarksHLm LineNr
" Make
:command -nargs=* Make make <args> | cwindow 3
let mapleader = ","
" Don't use Ex mode, use Q for formatting
map Q gq
" highlight trailing whitespace
" set listchars=tab:▷⋅,trail:·,eol:$
nmap <silent> <leader>s :set nolist!<CR>
" extended '%' mapping for if/then/else/end etc
runtime macros/matchit.vim
" Set easymotion leadery
let g:EasyMotion_leader_key = '\'
let g:EasyMotion_mapping_t = '\'
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
" Ctrl-R to disable search match highlight
nmap <silent> <C-W> :silent noh<CR>
" Ctrol-E to switch between 2 last buffers
nmap <C-6> :b#<CR>
" Ctrl-P to Display the file browser tree
nmap <F9> :NERDTreeToggle<CR>:set number<CR>:set nonumber<CR>
" ,p to show current file in the tree
nmap <leader>p :NERDTreeFind<CR>
" ,/ to invert comment on the current line/selection
nmap <leader>/ :call NERDComment(0, "invert")<cr>
vmap <leader>/ :call NERDComment(0, "invert")<cr>
" Align plugin
vmap <C-A> :Align! =<P0
" Tag navigation
let Tlist_Show_Menu=1
nmap <F8> :TlistToggle<CR>
" ,b to display current buffers list
let g:miniBufExplVSplit = 25
let g:miniBufExplorerMoreThanOne = 100
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplSplitToEdge = 0
nmap <F4> :MiniBufExplorer<cr>
let g:Conque_Read_Timeout = 50 " timeout for waiting for command output.
let g:Conque_TERM = 'xterm'
" ,sh to open vimshell window
nmap <Leader>sh :ConqueTermVSplit zsh<cr>
" ,r to open vimshell window
nmap <Leader>r :ConqueTermVSplit
" Tabs, create and navigate
nmap <C-N> :tabedit<CR>
nmap <silent> <S-Left> :tabprevious<CR>
nmap <silent> <S-Right> :tabnext<CR>
" map ,y to show the yankring
nmap <leader>y :YRShow<cr>
if has("mouse")
set mouse=a
endif
let g:yankring_replace_n_pkey = '<leader>['
let g:yankring_replace_n_nkey = '<leader>]'
set shell=/usr/bin/zsh
set tabstop=2
set shiftwidth=2
set expandtab
" nnoremap / /\v
" vnoremap / /\v
set textwidth=0 " Do not wrap words (insert)
set nowrap " Do not wrap words (view)
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " do not ignore if search pattern has CAPS
set incsearch " Incremental search
set autowriteall " Automatically save before commands like :next and :make
set hlsearch " Highlight search match
set hidden " enable multiple modified buffers
set nobackup " do not write backup files
set foldcolumn=2 " columns for folding
set foldmethod=indent
set foldlevel=300
set history=1000
set wildmenu
set ruler
" set visualbell
set gdefault " Search&Replace includes /g by default
au FocusLost * :wa " Auto save when losing focus
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
nnoremap <leader>ft Vatzf " Fold block
nnoremap <leader>w <C-w>v<C-w>l " Open vertical split
nnoremap <C-h> <C-w>h " Navigate splits
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Search and replace current word
nnoremap <F2> :%s/\<<C-r><C-w>\>/
" Show yank history
nnoremap <silent> <F3> :YRShow<cr> " For the yanking plugin
inoremap <silent> <F3> <ESC>:YRShow<cr>
" Use C-P and C-N to cycle between old yanks after a past
let g:yankring_replace_n_pkey = '<C-P>'
let g:yankring_replace_n_nkey = '<C-N>'
nmap <leader>e :CommandT<CR>
nmap <leader>E :CommandTFlush<CR>
"set relativenumber
"set colorcolumn=85
set undofile " Create an unfo files to undos work across closes
set bs=2
set sw=2
" fix backspace not deleting lines
set backspace=indent,eol,start
nmap <leader>o :put=''<CR>
nmap <leader>O :put!=''<CR>
nmap <leader>v <Esc>:vsplit<CR>
nmap <leader>s <Esc>:split<CR>
nmap <leader>t <Esc>:tabnew<CR>
nmap <leader><leader> :ZoomWin<CR>
" Cause automatic aligned around = or : characters
let mapleader=','
if exists(":Tabularize")
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
endif
autocmd FileType html,xhtml,xml,htmldjango,jinjahtml,eruby,mako source ~/.vim/bundle/closetag/plugin/closetag.vim
" New
set showcmd
inoremap jj <Esc>
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set undodir=~/.vim/undo
" Set special syntax highliting
au BufReadPost *.rabl set syntax=ruby
" Markdown files end in .md
au BufRead,BufNewFile *.md set filetype=markdown
" rspec mappings
map <Leader>1 :call RunCurrentSpecFile()<CR>
map <Leader>2 :call RunNearestSpec()<CR>
map <Leader>3 :call RunLastSpec()<CR>
function! RunCurrentSpecFile()
if InSpecFile()
let l:command = "s " . @% . " -f documentation"
call SetLastSpecCommand(l:command)
call RunSpecs(l:command)
endif
endfunction
function! RunNearestSpec()
if InSpecFile()
let l:command = "s " . @% . " -l " . line(".") . " -f documentation"
call SetLastSpecCommand(l:command)
call RunSpecs(l:command)
endif
endfunction
function! RunLastSpec()
if exists("t:last_spec_command")
call RunSpecs(t:last_spec_command)
endif
endfunction
function! InSpecFile()
return match(expand("%"), "_spec.rb$") != -1
endfunction
function! SetLastSpecCommand(command)
let t:last_spec_command = a:command
endfunction
function! RunSpecs(command)
execute ":w\|!clear && echo " . a:command . " && echo && " . a:command
endfunction