Viewing Zip files
There are several plugins that comes standard with Vim. Netrw is one we’ve covered some of already: Editing remote files and file system exploration. There’s another plugin that comes standard with Vim: zip.vim. This adds the ability to navigate through a compressed file archive without decompressing it. You can even edit files inside the archive while in Vim. They are compressed back into the archive when written to disk.
To use, simply open the file in Vim: :e my_file.zip
and Vim will display a list of the contents and directory structure. Watch the Gif below. In it, I open a file called posts.zip
and then open a Markdown file contained in that Zip. When I edit the file and write the buffer with :w
, then the modified contents are persisted back to the Zip.

This Zip file navigation trick works on other compressed archive formats, such as Tar and Gzip archives, thanks to some other plugins that ship with Vim. In fact, since a number of well-known file formats like Microsoft Office documents are essentially Zip archives with another extension, you can use this trick on a whole host of other file types like .docx
and .xlsx
.
Check out the source code of the zipPlugin.vim file in Vim for the full list.
I’m curious how to set the encoding before reading the file. I stumbled upon the old zip with assembler code, where all comments were written in Russian in the old cp866 encoding. But I use Linux, so had to make the reading of encoded text with Python. Is it possible to set encoding inside Vim?
Actually, I’ve found the answer, and that is easy. Before entering in the old zipped code I had to run :set fileencodings=cp866
(except the part where I tried to no avail to run the command: set fileencoding=cp866, the ‘s’ in the end proved to be crucial, don’t know why at the moment)