1
2 Last Change:
3 Author:
4 URL:http://peterodding.com/code/vim/reload/
5 License:
6 Version:
7
8
9 GetLatestVimScripts::AutoInstall
10
11 if !exists('g:reload_on_write')
12 let g:reload_on_write = 1
13 endif
14
15 command! -bar -nargs=? -complete=file ReloadScript call s:ReloadCmd(<q-args>)
16
17 augroup PluginReloadScripts
18 autocmd!
19 autocmd BufWritePost *.vim nested call s:AutoReload()
20
21 autocmd SwapExists * call xolox#reload#open_readonly()
22 autocmd TabEnter * call xolox#reload#windows()
23 augroup END
24
25 function! s:ReloadCmd(arg)
26 if a:arg !~ '\S'
27 call xolox#reload#script(expand('%:p'))
28 else
29 call xolox#reload#script(fnamemodify(a:arg, ':p'))
30 endif
31 endfunction
32
33 if !exists('s:auto_reload_active')
34 function! s:AutoReload()
35 if g:reload_on_write
36 let s:auto_reload_active = 1
37 call xolox#reload#script(expand('%:p'))
38 unlet s:auto_reload_active
39 endif
40 endfunction
41 endif
42
43