2

I know that vim can open files within zip or tar{,.gz} archives interactively: open the archive first, then navigate to the correct entry and press enter.

lesspipe (https://github.com/wofr06/lesspipe) (which is a preprocessor for less) provides the additional convenience of allowing one to directly input both the archive name and the name of the file within the archive at the same time (less foo.tgz:file-within-foo) (yes, I know, such a scheme leads, in theory, to issues with files containing colons in their names; in practice this is rare...). I was wondering if a similar ability was available (perhaps as a plugin) for vim.

Clarification: Fundamentally, what I'm asking for should be "relatively" simple (and mostly focused on a usability POV), because most of the archive-handling ability is actually already present in vim: I am just looking for a plugin that will transform, say, vim foo.tgz:file-within to vim foo.tgz followed by selecting file-within in the listing offered by vim.

  • you want to see the content of a .rar file from vim which is not possible. but vim can show the content of zip or tar{,.gz}. – Mongrel Jun 15 '16 at 4:08
  • nope, .tgz is just .tar.gz. – antony Jun 15 '16 at 4:49
1

Most Unix variants support FUSE, which allows programs to define new filesystem types. There are several FUSE filesystems that expose archive contents as a directory tree. This way any application can see archive contents as ordinary files transparently. See Can I store and work with a directory in compressed form?

For example, with avfs, you get read-only access:

mountavfs
cd ~/.avfs$PWD
vim foo.tgz\#/file-within-foo

With archivemount, you need to mount each archive explicitly, but you get read-write access.

mkdir foo.d
archivemount foo.tgz foo.d
vim foo.d/file-within-foo
fusermount -u foo.d; rmdir foo.d

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.