Karsten Hopp cf9f5a
" Vim plugin for editing compressed files.
Karsten Hopp cf9f5a
" Maintainer: Bram Moolenaar <Bram@vim.org>
Karsten Hopp cf9f5a
" Last Change: 2005 Jul 26
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" Exit quickly when:
Karsten Hopp cf9f5a
" - this plugin was already loaded
Karsten Hopp cf9f5a
" - when 'compatible' is set
Karsten Hopp cf9f5a
" - some autocommands are already taking care of compressed files
Karsten Hopp cf9f5a
if exists("loaded_gzip") || &cp || exists("#BufReadPre#*.gz")
Karsten Hopp cf9f5a
  finish
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
let loaded_gzip = 1
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
augroup gzip
Karsten Hopp cf9f5a
  " Remove all gzip autocommands
Karsten Hopp cf9f5a
  au!
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " Enable editing of gzipped files.
Karsten Hopp cf9f5a
  " The functions are defined in autoload/gzip.vim.
Karsten Hopp cf9f5a
  "
Karsten Hopp cf9f5a
  " Set binary mode before reading the file.
Karsten Hopp cf9f5a
  " Use "gzip -d", gunzip isn't always available.
Karsten Hopp cf9f5a
  autocmd BufReadPre,FileReadPre	*.gz,*.bz2,*.Z setlocal bin
Karsten Hopp cf9f5a
  autocmd BufReadPost,FileReadPost	*.gz  call gzip#read("gzip -dn")
Karsten Hopp cf9f5a
  autocmd BufReadPost,FileReadPost	*.bz2 call gzip#read("bzip2 -d")
Karsten Hopp cf9f5a
  autocmd BufReadPost,FileReadPost	*.Z   call gzip#read("uncompress")
Karsten Hopp cf9f5a
  autocmd BufWritePost,FileWritePost	*.gz  call gzip#write("gzip")
Karsten Hopp cf9f5a
  autocmd BufWritePost,FileWritePost	*.bz2 call gzip#write("bzip2")
Karsten Hopp cf9f5a
  autocmd BufWritePost,FileWritePost	*.Z   call gzip#write("compress -f")
Karsten Hopp cf9f5a
  autocmd FileAppendPre			*.gz  call gzip#appre("gzip -dn")
Karsten Hopp cf9f5a
  autocmd FileAppendPre			*.bz2 call gzip#appre("bzip2 -d")
Karsten Hopp cf9f5a
  autocmd FileAppendPre			*.Z   call gzip#appre("uncompress")
Karsten Hopp cf9f5a
  autocmd FileAppendPost		*.gz  call gzip#write("gzip")
Karsten Hopp cf9f5a
  autocmd FileAppendPost		*.bz2 call gzip#write("bzip2")
Karsten Hopp cf9f5a
  autocmd FileAppendPost		*.Z   call gzip#write("compress -f")
Karsten Hopp cf9f5a
augroup END