Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open gzip text files in Gvim without unzipping?

Tags:

How to open Gzipped text files (*.gz) in Gvim without unzipping them first ?

like image 798
Jean Avatar asked Mar 22 '11 18:03

Jean


2 Answers

Vim should do this for you automatically. At least it does for me. There's also zless. I'll see if I can find a resource that talks about how vim does this.

like image 42
Bradford Avatar answered Oct 05 '22 00:10

Bradford


Solution mentioned in VimDocs as answered by therefromwhere

augroup gzip
 autocmd!
 autocmd BufReadPre,FileReadPre *.gz set bin
 autocmd BufReadPost,FileReadPost   *.gz '[,']!gunzip
 autocmd BufReadPost,FileReadPost   *.gz set nobin
 autocmd BufReadPost,FileReadPost   *.gz execute ":doautocmd BufReadPost " . expand("%:r")
 autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
 autocmd BufWritePost,FileWritePost *.gz !gzip <afile>:r
 autocmd FileAppendPre      *.gz !gunzip <afile>
 autocmd FileAppendPre      *.gz !mv <afile>:r <afile>
 autocmd FileAppendPost     *.gz !mv <afile> <afile>:r
 autocmd FileAppendPost     *.gz !gzip <afile>:r
augroup END
like image 71
Jean Avatar answered Oct 05 '22 02:10

Jean