On Wednesday, August 21, 2013 2:57:51 AM UTC+5:30, skeept wrote:
> Is there a way of enabling swap files for files say less than 10Mb but disabling swap files for files or larger sizes?
>
> Thanks,
>
> Jorge
Hi,
Here's something I use:
let g:BufSizeThresholdSmall = 500000 " No swap threshold (Set to 500 KB)
let g:BufSizeThresholdBig = 1000000000 " Minimal mode threshold (Set to 1 GB)
" For small files, switch all options on
autocmd BufEnter * if getfsize(expand("<afile>")) < g:BufSizeThresholdSmall | set incsearch | setlocal statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P | endif
" Don't use a swap file for big files
autocmd BufReadPre * if getfsize(expand("<afile>")) >= g:BufSizeThresholdSmall | setlocal noswapfile | setlocal statusline=%<%f\ %h%m%r\ No\ Swap\ File%=%-14.(%l,%c%V%)\ %P | endif
" Switch off other options for still bigger files
autocmd BufEnter * if getfsize(expand("<afile>")) >= g:BufSizeThresholdBig | set noincsearch | setlocal noswapfile | setlocal statusline=%<%f\ %h%m%r\ No\ Swap\ File.\ No\ Incsearch%=%-14.(%l,%c%V%)\ %P | endif
It allows two thresholds and disables more options for very large files. Moreover, the status line is updated to reflect the current state of options so that I know what to expect for the currently open file.
PS: I don't remember if I copied it from somewhere or built it over time. In either case, corrections and suggestions for improvement are welcome. Will help me learn something new. :)
Best Regards,
Abhishek
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment