aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/LargeFile.vim
diff options
context:
space:
mode:
authorBen Beltran <ben@freshout.us>2013-03-25 16:36:57 -0600
committerBen Beltran <ben@freshout.us>2013-03-25 16:36:57 -0600
commit32081fee7621ff912a91fb1576ed5961deb476e4 (patch)
tree16d5d257cba6a3f4c9eb27fbfc3648e68153e83a /vim/plugin/LargeFile.vim
parent25c3fb22714ee393b4fe72c92269d732b9102268 (diff)
Update the stuff
Diffstat (limited to 'vim/plugin/LargeFile.vim')
-rw-r--r--vim/plugin/LargeFile.vim80
1 files changed, 80 insertions, 0 deletions
diff --git a/vim/plugin/LargeFile.vim b/vim/plugin/LargeFile.vim
new file mode 100644
index 0000000..9f6551e
--- /dev/null
+++ b/vim/plugin/LargeFile.vim
@@ -0,0 +1,80 @@
+" LargeFile: Sets up an autocmd to make editing large files work with celerity
+" Author: Charles E. Campbell, Jr.
+" Date: Sep 23, 2008
+" Version: 4
+" GetLatestVimScripts: 1506 1 :AutoInstall: LargeFile.vim
+
+" ---------------------------------------------------------------------
+" Load Once: {{{1
+if exists("g:loaded_LargeFile") || &cp
+ finish
+endif
+let g:loaded_LargeFile = "v4"
+let s:keepcpo = &cpo
+set cpo&vim
+
+" ---------------------------------------------------------------------
+" Commands: {{{1
+com! Unlarge call s:Unlarge()
+com! -bang Large call s:LargeFile(<bang>0,expand("%"))
+
+" ---------------------------------------------------------------------
+" Options: {{{1
+if !exists("g:LargeFile")
+ let g:LargeFile= 20 " in megabytes
+endif
+
+" ---------------------------------------------------------------------
+" LargeFile Autocmd: {{{1
+" for large files: turns undo, syntax highlighting, undo off etc
+" (based on vimtip#611)
+augroup LargeFile
+ au!
+ au BufReadPre * call <SID>LargeFile(0,expand("<afile>"))
+ au BufReadPost *
+ \ if &ch < 2 && (getfsize(expand("<afile>")) >= g:LargeFile*1024*1024 || getfsize(expand("<afile>")) == -2)
+ \| echomsg "***note*** handling a large file"
+ \| endif
+augroup END
+
+" ---------------------------------------------------------------------
+" s:LargeFile: {{{2
+fun! s:LargeFile(force,fname)
+" call Dfunc("LargeFile(force=".a:force." fname<".a:fname.">)")
+ if a:force || getfsize(a:fname) >= g:LargeFile*1024*1024 || getfsize(a:fname) <= -2
+ syn clear
+ let b:eikeep = &ei
+ let b:ulkeep = &ul
+ let b:bhkeep = &bh
+ let b:fdmkeep= &fdm
+ let b:swfkeep= &swf
+ set ei=FileType
+ setlocal noswf bh=unload fdm=manual ul=-1
+ let fname=escape(substitute(a:fname,'\','/','g'),' ')
+ exe "au LargeFile BufEnter ".fname." set ul=-1"
+ exe "au LargeFile BufLeave ".fname." let &ul=".b:ulkeep."|set ei=".b:eikeep
+ exe "au LargeFile BufUnload ".fname." au! LargeFile * ". fname
+ echomsg "***note*** handling a large file"
+ endif
+" call Dret("s:LargeFile")
+endfun
+
+" ---------------------------------------------------------------------
+" s:Unlarge: this function will undo what the LargeFile autocmd does {{{2
+fun! s:Unlarge()
+" call Dfunc("s:Unlarge()")
+ if exists("b:eikeep") |let &ei = b:eikeep |endif
+ if exists("b:ulkeep") |let &ul = b:ulkeep |endif
+ if exists("b:bhkeep") |let &bh = b:bhkeep |endif
+ if exists("b:fdmkeep")|let &fdm = b:fdmkeep|endif
+ if exists("b:swfkeep")|let &swf = b:swfkeep|endif
+ syn on
+ doau FileType
+" call Dret("s:Unlarge")
+endfun
+
+" ---------------------------------------------------------------------
+" Restore: {{{1
+let &cpo= s:keepcpo
+unlet s:keepcpo
+" vim: ts=4 fdm=marker