-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
212 lines (189 loc) · 5.47 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
call plug#begin('~/.vim/vim-plugins')
Plug '907th/vim-auto-save'
Plug 'FelikZ/ctrlp-py-matcher'
Plug 'Lokaltog/vim-easymotion'
Plug 'Raimondi/delimitMate'
Plug 'Shutnik/jshint2.vim', { 'for': 'javascript' }
Plug 'airblade/vim-gitgutter'
Plug 'ap/vim-css-color', { 'for': ['css', 'less'] }
Plug 'bling/vim-airline'
Plug 'craigemery/vim-autotag'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'derekwyatt/vim-scala', { 'for': 'scala' }
Plug 'elzr/vim-json', { 'for' : 'json' }
Plug 'ervandew/supertab'
Plug 'https://github.com/kien/rainbow_parentheses.vim.git'
Plug 'jiangmiao/auto-pairs'
Plug 'majutsushi/tagbar'
Plug 'mustache/vim-mustache-handlebars'
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'mattn/emmet-vim'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-endwise', { 'for': 'ruby' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rails', { 'for': 'ruby' }
Plug 'tpope/vim-surround'
Plug 'tpope/vim-sleuth'
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
call plug#end()
set nocompatible
set autoindent
set autowrite
set background=dark
set backspace=indent,eol,start
set backupdir=$HOME/.vim-backup
set completeopt-=preview
set copyindent
set dir=$HOME/.vim-backup
set expandtab
set gdefault "srch & replace is global by default. Use /g to toggle behaviour
set hidden
set history=100
set hlsearch
set ignorecase
set incsearch
set laststatus=2 "display the status line always
set lazyredraw
set nostartofline
set number
set pastetoggle=<F2>
set previewheight=50
set ruler
set scrolloff=5
set shiftwidth=4
set showcmd
set showmatch
set noshowmode
set smartcase "but sensitive if Caps are used
set smartindent
set smarttab
set softtabstop=2
set splitbelow
set splitright
set tabpagemax=60
set tabstop=2
set ttyfast
set virtualedit+=block
set wildignore=*.swp,*.class,*.bak,*.git
set wildmenu
set wildmode=list:longest,full
set winheight=999 "split window heights
syntax on
filetype on
filetype indent on
filetype plugin on
let mapleader=","
map <Leader> <Plug>(easymotion-prefix)
let g:user_emmet_install_global = 0
let g:user_emmet_leader_key='M'
au FileType html,css EmmetInstall
let g:ctrlp_show_hidden = 0
let g:ctrlp_custom_ignore = 'target'
let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
else
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_prompt_mappings = { 'AcceptSelection("e")': ['<space>', '<cr>', '<2-LeftMouse>'] }
endif
let g:auto_save = 1
let g:auto_save_in_insert_mode = 0
let NERDTreeIgnore=['^\.class$', '^\.old$']
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
let g:gist_browser_command = 'google-chrome %URL%'
let g:ragtag_global_maps = 0
let g:airline#extensions#tabline#enabled = 1
nmap <C-D> :NERDTreeToggle<CR>
nmap <C-A> :TagbarToggle<CR>
nmap <leader>/ :RainbowParenthesesToggle<CR>
cabbr <expr> %% expand('%:p:h')
cmap w!! w !sudo tee % >/dev/null
imap <F1> <Esc>
imap <leader>h #{}<Esc>h
imap <silent> <C-G> <% end %><CR>
imap <silent> <C-K> <% %><Esc>2hi
imap <silent> <C-L> <%= %><Esc>2hi
imap <silent> <leader>cf console.info()<Esc>i
imap <silent> <leader>ci console.info('')<Esc>hi
imap <silent> <leader>ct console.time('')<Esc>hi
imap <silent> <leader>cte console.timeEnd('')<Esc>hi
imap \\ <CR><Esc>O
inoremap jj <ESC>
map <F1> <Esc>
map <F3> :set nonu!<CR>:set nonu?<CR>
map <F5> :set nolist!<CR>:set nolist?<CR>
map <F6> :set nohls!<CR>:set nohls?<CR>
map <leader>dc :%s/^\(.*\)$/\1 \1/<CR>
map <leader>sw :%s/\s\+$//<CR>
map <leader>b :ls<CR>:b<Space>
map <leader>l :ls<CR>
map <leader>n :bn<CR>
map <leader>p :bp<CR>
map Q <Esc>
map q: :q
nmap <silent> // :nohlsearch<CR>
nmap <silent> <leader>cf <ESC>/\v^[<=>]{7}( .*\|$)<CR>
nnoremap / /\v
nnoremap <C-j> ddpkJ
nnoremap <CR> o<ESC>
nmap <leader>o :CtrlP<CR>
nmap <leader>ob :CtrlPBuffer<CR>
nmap <leader>om :CtrlPMixed<CR>
nmap <leader>or :CtrlPMRU<CR>
nmap <leader>ot :CtrlPTag<CR>
nnoremap <leader><leader> <c-^>
nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
nnoremap <leader>ft Vatzf
nnoremap <leader>s :%s//<left>
nnoremap <silent> j gj
nnoremap <silent> k gk
nnoremap <silent> ss <C-w>s
nnoremap <silent> vv <C-w>v
nnoremap <tab> %
nnoremap D d$
nnoremap Y y$
noremap <S-tab> <C-b>
noremap <space> <C-f>
vnoremap / /\v
vnoremap <silent> j gj
vnoremap <silent> k gk
vnoremap <tab> %
:command! WQ wq
:command! Wq wq
:command! W w
:command! Q q
:command! Qa qa
:command! Wqa wqa
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview
au BufRead,BufNewFile {Gemfile,Rakefile,config.ru} set ft=ruby
au BufReadCmd *.epub call zip#Browse(expand("<amatch>"))
" hack from here http://stackoverflow.com/questions/3712725/can-i-change-vim-completion-preview-window-height
au BufEnter ?* call PreviewHeightWorkAround()
func! PreviewHeightWorkAround()
if &previewwindow
exec 'setlocal winheight='.&previewheight
endif
endfunc
" Use tilde to toggle between title, upper and lower case
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
else
let result = toupper(a:str)
endif
return result
endfunction
vnoremap ~ ygv"=TwiddleCase(@")<CR>Pgv
" Wraps paths to make them relative to this directory.
function! Dot(path)
return '~/.vim/' . a:path
endfunction