656023871997a70b640f9f4e52b727fc05aa2df2
[MacVim.git] / runtime / plugin / gzip.vim
blob656023871997a70b640f9f4e52b727fc05aa2df2
1 " Vim plugin for editing compressed files.
2 " Maintainer: Bram Moolenaar <Bram@vim.org>
3 " Last Change: 2005 Jul 26
5 " Exit quickly when:
6 " - this plugin was already loaded
7 " - when 'compatible' is set
8 " - some autocommands are already taking care of compressed files
9 if exists("loaded_gzip") || &cp || exists("#BufReadPre#*.gz")
10   finish
11 endif
12 let loaded_gzip = 1
14 augroup gzip
15   " Remove all gzip autocommands
16   au!
18   " Enable editing of gzipped files.
19   " The functions are defined in autoload/gzip.vim.
20   "
21   " Set binary mode before reading the file.
22   " Use "gzip -d", gunzip isn't always available.
23   autocmd BufReadPre,FileReadPre        *.gz,*.bz2,*.Z setlocal bin
24   autocmd BufReadPost,FileReadPost      *.gz  call gzip#read("gzip -dn")
25   autocmd BufReadPost,FileReadPost      *.bz2 call gzip#read("bzip2 -d")
26   autocmd BufReadPost,FileReadPost      *.Z   call gzip#read("uncompress")
27   autocmd BufWritePost,FileWritePost    *.gz  call gzip#write("gzip")
28   autocmd BufWritePost,FileWritePost    *.bz2 call gzip#write("bzip2")
29   autocmd BufWritePost,FileWritePost    *.Z   call gzip#write("compress -f")
30   autocmd FileAppendPre                 *.gz  call gzip#appre("gzip -dn")
31   autocmd FileAppendPre                 *.bz2 call gzip#appre("bzip2 -d")
32   autocmd FileAppendPre                 *.Z   call gzip#appre("uncompress")
33   autocmd FileAppendPost                *.gz  call gzip#write("gzip")
34   autocmd FileAppendPost                *.bz2 call gzip#write("bzip2")
35   autocmd FileAppendPost                *.Z   call gzip#write("compress -f")
36 augroup END