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.
Was this useful? Help us improve!
With your feedback, we can improve VimTricks. Click a link to vote: