3

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.

2
  • 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}. Commented Jun 15, 2016 at 4:08
  • nope, .tgz is just .tar.gz. Commented Jun 15, 2016 at 4:49

1 Answer 1

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 e.g. here).

  • 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
    

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.