-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
326 lines (254 loc) · 8.21 KB
/
vimrc
File metadata and controls
326 lines (254 loc) · 8.21 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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
set nocompatible " Use vim, no vi defaults
let mapleader = ","
if filereadable(expand("~/.vimrc.bundles"))
source ~/.vimrc.bundles
endif
filetype plugin indent on " Turn on filetype plugins
set number " Show line numbers
set relativenumber " use hybrid line number mode
set numberwidth=5 " Bit more breathing room
set ruler " Show line and column number
syntax enable " Turn on syntax highlighting allowing local overrides
set encoding=utf-8 " Set default encoding to UTF-8"
set t_Co=256
set t_ut=
set noshowmode " Don't show mode twice with powerline enabled
set showcmd
set hidden
set laststatus=2 " Always show the status bar
set visualbell
set cmdheight=2
set lazyredraw
set backspace=2 " Sane backspace in insert mode
set nofoldenable " Code Folding sucks
set autoread
set autowriteall
" Don't add the comment prefix when I hit enter or o/O on a comment line
set formatoptions-=ro
" Don't wait so long for next keypress
set timeoutlen=500
" no swap, no backup
set nobackup
set nowritebackup
set noswapfile
" Persistent undos
if has('persistent_undo')
set undodir=~/.vim/undodir
set undofile
set undolevels=3000
set undoreload=10000
endif
if has('gui_running')
set guifont=DejaVu_Sans_Mono_for_Powerline:h11
endif
" Whitespace, softtabs, 2 spaces
set nowrap
set tabstop=2
set shiftwidth=2
set expandtab
set list
set autoindent
set smartindent
set shiftround " Smarter indenting
" List chars
set listchars=""
set listchars=tab:\ \
set listchars+=trail:·
set listchars+=tab:»·
set listchars+=extends:>
set listchars+=precedes:<
set showbreak=↪ " Visualize wrapped lines when wrap toggled
" only show cursorline in the current window and in normal mode
set cursorline
augroup cline
au!
au WinLeave * set nocursorline
au WinEnter * set cursorline
au InsertEnter * set nocursorline
au InsertLeave * set cursorline
au BufNewFile,BufRead *.jscsrc set filetype=javascript
au BufNewFile,BufRead *.jsx.erb set filetype=javascript.jsx
au BufReadPost *.conf set syntax=ini
au BufReadPost .babelrc set syntax=json
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
au BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
augroup vimrc
autocmd!
autocmd BufWinEnter,Syntax * syn sync minlines=500 maxlines=500
augroup END
if exists('+colorcolumn')
set colorcolumn=80 " highlight column 80
endif
" set filetypes
" Save when losing focus (does not work in ubuntu terminal)
" au FocusLost * silent! wa
" Searching
set hlsearch " highlight matches
set incsearch " incremental searching
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
" Wild settings
" Disable output and VCS files
set wildignore+=*.o,*.out,*.obj,.git,*.rbc,*.rbo,*.class,.svn,*.gem
" Disable archive files
set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz
" Ignore bundler and sass cache
set wildignore+=*/vendor/gems/*,*/vendor/cache/*,*/.bundle/*,*/.sass-cache/*
" Ignore librarian-chef, vagrant, test-kitchen and Berkshelf cache
set wildignore+=*/tmp/librarian/*,*/.vagrant/*,*/.kitchen/*,*/vendor/cookbooks/*
" Ignore rails temporary asset caches
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/*
" Disable temp and backup files
set wildignore+=*.swp,*~,._*
set wildignore+=.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc,tmp,*.scssc
set wildmenu
" More natural feeling split positions.
" set splitright
" set splitbelow
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g "" --ignore-dir={"node*modules","build","log","*.jpg","tmp","*.png","*.gif","bower_components","dist"}'
endif
" buffergator splits horizontal bottom (full screen width)
let g:buffergator_viewport_split_policy = "B"
" map <leader>b :BuffergatorToggle<CR>
" nnoremap <leader>b :BuffergatorToggle<CR>
" Show current file in NERDTree
map <silent> <Leader>s :NERDTree<CR><C-w>p:NERDTreeFind<CR>:set cursorline<CR>
" ctrl-s for save
command -nargs=0 -bar Update if &modified
\| if empty(bufname('%'))
\| browse confirm write
\| else
\| confirm write
\| endif
\|endif
nnoremap <silent> <C-S> :<C-u>Update<CR>
inoremap <c-s> <Esc>:Update<CR>
map <C-F> :Ag<space>
map <leader>n :NERDTreeToggle<CR> :NERDTreeMirror<CR>
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunc
nnoremap <leader>tn :call NumberToggle()<cr>
" not working, dont know why...
" augroup numtoggle
" au!
" au WinLeave * set norelativenumber
" au WinLeave * set relativenumber
" au InsertEnter * set norelativenumber
" au InsertLeave * set relativenumber
" augroup END
" disable vimux slime hotkeys for now
" function! VimuxSlime()
" call VimuxOpenPane()
" call VimuxSendText(@v)
" call VimuxSendKeys("Enter")
" endfunction
" If text is selected, save it in the v buffer and send that buffer to tmux
" vmap <leader>vs "vy :call VimuxSlime()<CR>
" Select current paragraph and send it to tmux
" nmap <leader>vs vip<leader>vs<CR>
" Automatically reload vimrc when it's saved
" au BufWritePost vimrc so ~/.vimrc
" Kill Trailing Whitespaces
command! KillWhitespace :normal :%s/ *$//g<cr><c-o><cr>
" Use sudo to write file
command! -bar SudoWrite :
\ setlocal nomodified |
\ exe (has('gui_running') ? '' : 'silent') 'write !sudo tee % >/dev/null' |
\ let &modified = v:shell_error
" Disable things nobody needs.
map Q <Nop>
map K <Nop>
" Don't jump when using * for search
nnoremap * *<C-o>
" Keep search pattern at the center of the screen
nnoremap <silent> n nzz
nnoremap <silent> N Nzz
"nnoremap <silent> * *zz
nnoremap <silent> # #zz
nnoremap <silent> g* g*zz
" Exit insert mode not leavin home row
inoremap jk <ESC>
" easy new lines in insert mode
imap <C-o> <ESC>o
" jump to end of line in insert mode
imap <silent> <C-e> <ESC>A
" Toggle paste mode
nmap <silent> <F4> :set invpaste<CR>
imap <silent> <F4> <ESC>:set invpaste<CR>
" set text wrapping toggles
nmap <silent> <leader>tw :set invwrap<CR>
" Bubble single lines
nmap <C-Up> [e
nmap <C-Down> ]e
nmap <C-k> [e
nmap <C-j> ]e
" Bubble multiple lines
vmap <C-Up> [egv
vmap <C-Down> ]egv
vmap <C-k> [egv
vmap <C-j> ]egv
" upper/lower word
nmap <leader>u mQviwU`Q
nmap <leader>l mQviwu`Q
" upper/lower first char of word
nmap <leader>U mQgewvU`Q
nmap <leader>L mQgewvu`Q
" cd to the directory containing the file in the buffer
nmap <silent> <leader>cd :lcd %:h<CR>
" Create the directory containing the file in the buffer
nmap <silent> <leader>md :!mkdir -p %:p:h<CR>
" Select all
map <Leader>a ggVG
" Open last/alternate buffer
map <Leader><Space> <C-^>
" Open current file in background tab
map <leader>te :tabedit %<CR>:tabprev<CR>
" Improve up / down movement on wrapped lines
nmap k gk
nmap j gj
" Jump to beginning / end
" imap <C-b> <C-o>^
" imap <C-e> <C-o>$
" cnoremap <C-b> <home>
" cnoremap <C-e> <end>
" quick new tab
map <C-t> <esc>:tabnew<CR>
" get rid of highlighting of last search result
nnoremap <CR> :noh<CR><CR>
" might be better
nnoremap <leader>h :noh<CR>
" easy split navigation
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" nnoremap <Up> 3<C-w>-
" nnoremap <Down> 3<C-w>+
" nnoremap <Left> 3<C-w><
" nnoremap <Right> 3<C-w>>
" nnoremap <Left> :echoe "Use h"<CR>
" nnoremap <Right> :echoe "Use l"<CR>
" nnoremap <Up> :echoe "Use k"<CR>
" nnoremap <Down> :echoe "Use j"<CR>
color xoria256
" color lucius
" LuciusWhiteHighContrast
hi IndentGuidesOdd ctermbg=234
" hi IndentGuidesEven ctermbg=255
source $HOME/.vimrc.local