-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_vimrc
executable file
·395 lines (326 loc) · 10.8 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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
set ff=dos
"===================================================================
" Vundle
"==================================================================
set nocompatible " be iMproved
filetype off " required!
if has('win32') || has('win64')
set rtp+=~/vim/vimfiles/bundle/Vundle.vim
call vundle#begin('$HOME/vim/vimfiles/bundle/')
else
" Usual quickstart instructions
set rtp+=~/.vim/vimfiles/bundle/Vundle.vim
call vundle#begin('$HOME/.vim/vimfiles/bundle/')
endif
call vundle#begin('$HOME/.vim/vimfiles/bundle/')
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
"
" My Bundles here:
"
" original repos on github
Bundle 'nelstrom/vim-markdown-folding'
Bundle 'maxmeyer/vim-taskjuggler.git'
Bundle 'scrooloose/nerdtree.git'
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'tpope/vim-rails.git'
Bundle 'vim-ruby/vim-ruby'
Bundle 'altercation/vim-colors-solarized'
Bundle 'vim-scripts/Vim-R-plugin'
Bundle 'godlygeek/tabular'
Bundle 'plasticboy/vim-markdown'
Bundle 'L9'
Bundle 'FuzzyFinder'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
" " ...
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "garbas/vim-snipmate"
Bundle "SirVer/ultisnips.git"
Bundle "honza/vim-snippets"
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
filetype plugin indent on " required!
set nocompatible
if has("autocmd")
filetype plugin indent on
endif
"===================================================================
" relocating swap files
"===================================================================
if has('win32') || has('win64')
set backupdir=$USERPROFILE/vim/temp
set dir=$USERPROFILE/vim/temp
else
set backupdir=~/.vim/temp
set dir=~/.vim/temp
endif
"===================================================================
" ...so that fugitive works
"===================================================================
set directory+=,~/tmp,$TMP
"===================================================================
" Autocompletion
"===================================================================
filetype plugin on
set ofu=syntaxcomplete#Complete
:imap jk <Esc>
:imap JK <Esc>
"===================================================================
" move chunks up/down
" this is not working as expected
"===================================================================
let @a = 'V}d}p'
nnoremap <A-J> @a
let @w = 'V}d{{p'
nnoremap <A-K> @w
nnoremap <A->> zr
nnoremap <A-lt> zm
nnoremap <A-p> gq}g;<C-O>
"===================================================================
" complete file path while typing
"===================================================================
set wildmode=longest,list,full
set wildmenu
"===================================================================
" Automatically closes brakets
" Taken from:
" http://vim.wikia.com/wiki/Automatically_append_closing_characters
"===================================================================
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
inoremap ( ()<Left>
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
" Incomplete example moving the cursor after insertion.
" DO NOT USE, use a plugin instead.
function! MoveLeft()
let newpos = getpos('.')
let newpos[2] -= 1
if (newpos[2] < 1)
let newpos[2] = 1
endif
call setpos('.', newpos)
return ""
endfunction
inoremap ( ()<C-R>=MoveLeft()<CR>
let $MYVIMRC = '$USERPROFILE\vim\_vimrc'
"===================================================================
" Tab characters
"===================================================================
:set tabstop=2
:set shiftwidth=2
:set expandtab
nnoremap <Tab> >>_
nnoremap <S-Tab> <<_
inoremap <S-Tab> <C-D>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
"===================================================================
" navigate buffers
"===================================================================
:nnoremap <C-n> :bnext<CR>
:nnoremap <C-p> :bprevious<CR>
"===================================================================
" Return characters in normal mode
"===================================================================
map <S-Enter> O<Esc>
map <CR> o<Esc>
"===================================================================
"===================================================================
set nocompatible
syntax enable
filetype plugin on
filetype indent on
"set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set hidden
"===================================================================
" Move lines up/down
"===================================================================
nnoremap <A-j> :m+<CR>==
nnoremap <A-k> :m-2<CR>==
inoremap <A-j> <Esc>:m+<CR>==gi
inoremap <A-k> <Esc>:m-2<CR>==gi
vnoremap <A-j> :m'>+<CR>gv=gv
vnoremap <A-k> :m-2<CR>gv=gv
"===================================================================
" Navigating tabs
"===================================================================
:nnoremap <F7> :tabp<CR>
:nnoremap <F8> :tabn<CR>
"===================================================================
" solarized color scheme
"===================================================================
syntax enable
set background=light
colorscheme solarized
if has('gui_running')
set background=light
else
set background=dark
endif
call togglebg#map("<F6>")
let g:solarized_italic=0 "default value is 1
let mapleader = ","
"===================================================================
" show row numbers
"===================================================================
:set number
"===================================================================
" VimOutliner
"===================================================================
filetype plugin indent on
syntax on
runtime! ftdetect\*.vim
au BufEnter *.otl setlocal tabstop = 2
au BufEnter *.otl setlocal shiftwidth = 2
"===================================================================
" Indentation
"===================================================================
set autoindent
"===================================================================
" Macro for date insertion
"===================================================================
"noremap <A-d> strftime("%m/%d/%y")
"
:nnoremap <F5> "=strftime("%m/%d/%y")<CR>P
:inoremap <F5> <C-R>=strftime("%m/%d/%y")<CR>
:inoremap <A-3> #'
:nnoremap <A-3> i#' <Esc>
"===================================================================
" Swap words
"===================================================================
:nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>
" This version will work across newlines:
:nnoremap <silent> gw "_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<CR><c-o><c-l>
"===================================================================
" Code Folding
"===================================================================
autocmd FileType R
\ set foldmethod=expr |
\ set foldexpr=getline(v:lnum)=~'^\\s*#\'''
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
" au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
au BufWinLeave ?* mkview
au BufWinEnter ?* silent loadview
"function! MarkdownFolds()
" let thisline = getline(v:lnum)
" if match(thisline, "^##") >= 0
" return ">2"
" elseif match(thisline, "^#") >= 0
" return ">1"
" else
" return "="
" endif
"endfunction
"function! MarkdownFoldText()
" let foldsize = (v:foldend-v:foldstart)
" return getline(v:foldstart).' ('.foldsize.' lines)'
"endfunction
"autocmd FileType Rmd
" \ set foldtext=MarkdownFoldText() |
" \ set foldcolumn=3 |
" \ set foldmethod=expr |
" \ set foldexpr=MarkdownFolds()
"===================================================================
" auto wraping text
"===================================================================
" set formatoptions-=tcqro
"
"
" " http://www.derekwyatt.org/vim/the-vimrc-file/
" set textwidth=120
"
augroup vimrc_autocmds
autocmd BufEnter * set textwidth=70
autocmd BufEnter *.R set textwidth=140
augroup END
" Increase history of executed commands (:).
set history=1000
" Increase number of possible undos.
set undolevels=1000
set diffexpr=MyDifference()
function MyDifference()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
"===================================================================
" Enable the installation of vimballs (vba files)
"===================================================================
" call vimball#Vimball("%:p:h")
function! VO2MD()
let lines = []
let was_body = 0
for line in getline(1,'$')
if line =~ '^\t*[^:\t]'
let indent_level = len(matchstr(line, '^\t*'))
if was_body " <= remove this line to have body lines separated
call add(lines, '')
endif " <= remove this line to have body lines separated
call add(lines, substitute(line, '^\(\t*\)\([^:\t].*\)', '\=repeat("#", indent_level + 1)." ".submatch(2)', ''))
call add(lines, '')
let was_body = 0
else
call add(lines, substitute(line, '^\t*: ', '', ''))
let was_body = 1
endif
endfor
silent %d _
call setline(1, lines)
endfunction
function! MD2VO()
let lines = []
for line in getline(1,'$')
if line =~ '^\s*$'
continue
endif
if line =~ '^#\+'
let indent_level = len(matchstr(line, '^#\+')) - 1
call add(lines, substitute(line, '^#\(#*\) ', repeat("\<Tab>", indent_level), ''))
else
call add(lines, substitute(line, '^', repeat("\<Tab>", indent_level) . ': ', ''))
endif
endfor
silent %d _
call setline(1, lines)
endfunction