1 " LargeFile: Sets up an autocmd to make editing large files work with celerity
2 " Author: Charles E. Campbell, Jr.
5 " GetLatestVimScripts: 1506 1 :AutoInstall: LargeFile.vim
7 " ---------------------------------------------------------------------
9 if exists("g:loaded_LargeFile") || &cp
12 let g:loaded_LargeFile = "v4"
16 " ---------------------------------------------------------------------
18 com! Unlarge call s:Unlarge()
19 com! -bang Large call s:LargeFile(<bang>0,expand("%"))
21 " ---------------------------------------------------------------------
23 if !exists("g:LargeFile")
24 let g:LargeFile= 20 " in megabytes
27 " ---------------------------------------------------------------------
28 " LargeFile Autocmd: {{{1
29 " for large files: turns undo, syntax highlighting, undo off etc
30 " (based on vimtip#611)
33 au BufReadPre * call <SID>LargeFile(0,expand("<afile>"))
35 \ if &ch < 2 && (getfsize(expand("<afile>")) >= g:LargeFile*1024*1024 || getfsize(expand("<afile>")) == -2)
36 \| echomsg "***note*** handling a large file"
40 " ---------------------------------------------------------------------
42 fun! s:LargeFile(force,fname)
43 " call Dfunc("LargeFile(force=".a:force." fname<".a:fname.">)")
44 if a:force || getfsize(a:fname) >= g:LargeFile*1024*1024 || getfsize(a:fname) <= -2
52 setlocal noswf bh=unload fdm=manual ul=-1
53 let fname=escape(substitute(a:fname,'\','/','g'),' ')
54 exe "au LargeFile BufEnter ".fname." set ul=-1"
55 exe "au LargeFile BufLeave ".fname." let &ul=".b:ulkeep."|set ei=".b:eikeep
56 exe "au LargeFile BufUnload ".fname." au! LargeFile * ". fname
57 echomsg "***note*** handling a large file"
59 " call Dret("s:LargeFile")
62 " ---------------------------------------------------------------------
63 " s:Unlarge: this function will undo what the LargeFile autocmd does {{{2
65 " call Dfunc("s:Unlarge()")
66 if exists("b:eikeep") |let &ei = b:eikeep |endif
67 if exists("b:ulkeep") |let &ul = b:ulkeep |endif
68 if exists("b:bhkeep") |let &bh = b:bhkeep |endif
69 if exists("b:fdmkeep")|let &fdm = b:fdmkeep|endif
70 if exists("b:swfkeep")|let &swf = b:swfkeep|endif
73 " call Dret("s:Unlarge")
76 " ---------------------------------------------------------------------
80 " vim: ts=4 fdm=marker