xref: /vim-8.2.3635/runtime/plugin/gzip.vim (revision c0880db6)
1" Vim plugin for editing compressed files.
2" Maintainer: Bram Moolenaar <[email protected]>
3" Last Change: 2009 Jul 01
4
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
9if exists("loaded_gzip") || &cp || exists("#BufReadPre#*.gz")
10  finish
11endif
12let loaded_gzip = 1
13
14augroup gzip
15  " Remove all gzip autocommands
16  au!
17
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,*.lzma 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 BufReadPost,FileReadPost	*.lzma call gzip#read("lzma -d")
28  autocmd BufWritePost,FileWritePost	*.gz  call gzip#write("gzip")
29  autocmd BufWritePost,FileWritePost	*.bz2 call gzip#write("bzip2")
30  autocmd BufWritePost,FileWritePost	*.Z   call gzip#write("compress -f")
31  autocmd BufWritePost,FileWritePost	*.lzma call gzip#write("lzma -z")
32  autocmd FileAppendPre			*.gz  call gzip#appre("gzip -dn")
33  autocmd FileAppendPre			*.bz2 call gzip#appre("bzip2 -d")
34  autocmd FileAppendPre			*.Z   call gzip#appre("uncompress")
35  autocmd FileAppendPre			*.lzma call gzip#appre("lzma -d")
36  autocmd FileAppendPost		*.gz  call gzip#write("gzip")
37  autocmd FileAppendPost		*.bz2 call gzip#write("bzip2")
38  autocmd FileAppendPost		*.Z   call gzip#write("compress -f")
39  autocmd FileAppendPost		*.lzma call gzip#write("lzma -z")
40augroup END
41