forked from vitaly/dotvim2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
252 lines (202 loc) · 8.08 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
" plugins/10-init/files -------------------
set nocompatible
set runtimepath^=~/.vim/dein/repos/github.com/Shougo/dein.vim
call dein#begin(expand('~/.vim/dein'))
source ~/.vim/vimrc.plugins
call dein#end()
filetype plugin indent on
if dein#check_install()
echo "installing plugins"
call dein#install()
endif
" plugins/20-settings/files -------------------
syntax on
" prevent vim from adding that stupid empty line at the end of every file
set noeol
set binary
" utf-8/unicode support
" requires Vim to be compiled with Multibyte support, you can check that by
" running `vim --version` and checking for +multi_byte.
if has('multi_byte')
scriptencoding utf-8
set encoding=utf-8
end
" presentation settings
set number " precede each line with its line number
set numberwidth=3 " number of culumns for line numbers
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 ruler " line and column number of the cursor position
set wildmenu " enhanced command completion
set visualbell " use visual bell instead of beeping
set laststatus=2 " always show the status line
"set listchars=tab:▷⋅,trail:·,eol:$
set listchars=tab:▷⋅,trail:·
set list
" highlight spell errors
hi SpellErrors guibg=red guifg=black ctermbg=red ctermfg=black
" behavior
" 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
set shell=/bin/bash " use bash for shell commands
set autowriteall " Automatically save before commands like :next and :make
set hidden " enable multiple modified buffers
set history=10000
set autoread " automatically read file that has been changed on disk and doesn't have changes in vim
set backspace=indent,eol,start
set guioptions-=T " disable toolbar"
set completeopt=menuone,preview
let bash_is_sh=1 " syntax shell files as bash scripts
set cinoptions=:0,(s,u0,U1,g0,t0 " some indentation options ':h cinoptions' for details
set modelines=5 " number of lines to check for vim: directives at the start/end of file
"set fixdel " fix terminal code for delete (if delete is broken but backspace works)
set autoindent " automatically indent new line
set ts=2 " number of spaces in a tab
set sw=2 " number of spaces for indent
set et " expand tabs into spaces
set ttimeoutlen=50 " fast Esc to normal mode
" mouse settings
if has("mouse")
set mouse=a
endif
set mousehide " Hide mouse pointer on insert mode."
" search settings
set incsearch " Incremental search
set hlsearch " Highlight search match
set ignorecase " Do case insensitive matching
set smartcase " do not ignore if search pattern has CAPS
" omni completion settings
set ofu=syntaxcomplete#Complete
let g:rubycomplete_buffer_loading = 0
let g:rubycomplete_classes_in_global = 1
" directory settings
call system('mkdir -vp ~/.backup/undo/ > /dev/null 2>&1')
set backupdir=~/.backup,. " list of directories for the backup file
set directory=~/.backup,~/tmp,. " list of directory names for the swap file
set nobackup " do not write backup files
set backupskip+=~/tmp/*,/private/tmp/* " skip backups on OSX temp dir, for crontab -e to properly work
set noswapfile " do not write .swp files
set undofile
set undodir=~/.backup/undo/,~/tmp,.
" folding
set foldcolumn=0 " columns for folding
set foldmethod=syntax
set foldlevel=9
set nofoldenable " dont fold by default "
" concealing
set concealcursor=
set conceallevel=2
" extended '%' mapping for if/then/else/end etc
runtime macros/matchit.vim
" Don't use Ex mode, use Q for formatting
map Q gq
" toggle highlight trailing whitespace
nmap <silent> <leader>s :set nolist!<CR>
" Ctrl-N to disable search match highlight
nmap <silent> <C-N> :silent noh<CR>
" Ctrol-E to switch between 2 last buffers
nmap <C-E> :b#<CR>
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
" ,n to get the next location (compilation errors, grep etc)
nmap <leader>n :cn<CR>
nmap <leader>N :cp<CR>
" ,d to diffupdate
nmap <leader>d :diffupdate<CR>
nmap <leader>dp :diffput<CR>
nmap <leader>dg :diffget<CR>
" driving me insane this thing
command Q q
command Qa qa
command QA qa
command -nargs=* -complete=file W w <args>
command -nargs=* -complete=file E e <args>
" plugins/20-settings/plugins/indent-level-navigation/files -------------------
" Jump to the next or previous line that has the same level or a lower
" level of indentation than the current line.
"
" exclusive (bool): true: Motion is exclusive
" false: Motion is inclusive
" fwd (bool): true: Go to next line
" false: Go to previous line
" lowerlevel (bool): true: Go to line with lower indentation level
" false: Go to line with the same indentation level
" skipblanks (bool): true: Skip blank lines
" false: Don't skip blank lines
function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
let line = line('.')
let column = col('.')
let lastline = line('$')
let indent = indent(line)
let stepvalue = a:fwd ? 1 : -1
while (line > 0 && line <= lastline)
let line = line + stepvalue
if ( ! a:lowerlevel && indent(line) == indent ||
\ a:lowerlevel && indent(line) < indent)
if (! a:skipblanks || strlen(getline(line)) > 0)
if (a:exclusive)
let line = line - stepvalue
endif
exe line
exe "normal " column . "|"
return
endif
endif
endwhile
endfunction
" Moving back and forth between lines of same or lower indentation.
nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
" plugins/20-settings/plugins/vimbits/files -------------------
" awesome stuff from vimbits.com
" keep selection after in/outdent
vnoremap < <gv
vnoremap > >gv
" better navigation of wrapped lines
nnoremap j gj
nnoremap k gk
" easier increment/decrement
nnoremap + <C-a>
nnoremap - <C-x>
" center display after searching
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#z
" disable paste mode when leaving Insert Mode
au InsertLeave * set nopaste
" fast expand current file's directory in command mode
cnoremap %% <C-R>=expand('%:h').'/'<cr>
cnoremap %^ <C-R>=expand('%:p:h').'/'<cr>
" remove trailing spaces
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<cr>
" Copy current buffer path relative to root of VIM session to system clipboard
nnoremap <Leader>Yp :let @*=expand("%")<cr>:echo "Copied file path to clipboard"<cr>
" Copy current filename to system clipboard
nnoremap <Leader>Yf :let @*=expand("%:t")<cr>:echo "Copied file name to clipboard"<cr>
" Copy current buffer path without filename to system clipboard
nnoremap <Leader>Yd :let @*=expand("%:h")<cr>:echo "Copied file directory to clipboard"<cr>
" keep at least 5 lines above/below cursor (when scrolling)
set scrolloff=5
" plugins/30-general/plugins/indent/lines -------------------
" prevent indent-lines from messing with concealing settings set globally
let g:indentLine_concealcursor = &concealcursor
let g:indentLine_conceallevel = &conceallevel
" plugins/70-languages/plugins/json/plugins/noconceal/files -------------------
let g:vim_json_syntax_conceal = 0