How to view zst file using Vim?

Viewed 3845

I'm trying to view some log files in zst format. I can use zstdcat to view the content, but when I do vim <filename.zst>, there're only garbled text. Is there a similar way as zstdcat to view zst file with Vim as well?

1 Answers

You use Zstandard to compress data so a *.zst file is not readable text and there is no point opening it directly in a text editor. You will have to decompress it first, which is what zstdcat does:

zstdcat is equivalent to zstd -dcf

and then open the decompressed text in Vim.

To view the content of a *.zst file in Vim, from your shell:

$ view <(zstdcat filename)
$ zstdcat filename | view -

To view the content of a *.zst file from Vim:

:enew | r !zstdcat filename

Note that, in both cases, you are not viewing the *.zst file itself but a copy of its decompressed content.

Of course, the whole thing could be streamlined and turned into a plugin similar to :h zip.

Related