From 32081fee7621ff912a91fb1576ed5961deb476e4 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Mon, 25 Mar 2013 16:36:57 -0600 Subject: Update the stuff --- vim/plugin/LargeFile.vim | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 vim/plugin/LargeFile.vim (limited to 'vim/plugin/LargeFile.vim') 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(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 LargeFile(0,expand("")) + au BufReadPost * + \ if &ch < 2 && (getfsize(expand("")) >= g:LargeFile*1024*1024 || getfsize(expand("")) == -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 -- cgit