Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open and edit a *.gz file within vim (with auto unzip/zip)

Tags:

vim

gzip

archive

Is it possible to auto unzip/zip *.gz files within vim?

like image 371
steveyang Avatar asked Apr 03 '12 16:04

steveyang


People also ask

How do I open a zip file in Vim?

To use, simply open the file in Vim: :e my_file. zip and Vim will display a list of the contents and directory structure.

How do I unzip a .GZ file in Linux?

You can unzip GZ files in Linux by adding the -d flag to the Gzip/Gunzip command. All the same flags we used above can be applied. The GZ file will be removed by default after we uncompressed it unless we use the -k flag. Below we will unzip the GZ files we compressed in the same directory.


3 Answers

My vim installation does this by default.

VIM - Vi IMproved 7.3 (2010 Aug 15) on OpenSUSE 12.1 

Also, check this link: http://ubuntuforums.org/showthread.php?t=902668

like image 80
Filip Avatar answered Sep 24 '22 18:09

Filip


zip/unzip cannot open *.gz files as far as I know.

Vim can open *.gz files with the help of gzip/gunzip like this

Its already discussed here on SO

How to open gzip text files in Gvim without unzipping?

like image 28
Pavan Manjunath Avatar answered Sep 23 '22 18:09

Pavan Manjunath


I have searched for this answer as well, specifically for Fedora.

So on Fedora, you need to install the package vim-enhanced:

sudo dnf install vim-enhanced

Now it is possible to just edit gzipped files like this:

vim my.log.gz 
like image 43
Timotheus Pokorra Avatar answered Sep 22 '22 18:09

Timotheus Pokorra