5

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?

Liutong Chen
  • 2,915
  • 5
  • 22
  • 29
  • Something like this: https://stackoverflow.com/a/5463559/7976758 but with different commands — `zstdcat` instead of `gz`. – phd Aug 13 '21 at 09:24
  • http://vimdoc.sourceforge.net/htmldoc/autocmd.html#gzip-example Found in https://stackoverflow.com/search?q=%5Bvim%5D+open+gzipped+file – phd Aug 13 '21 at 09:24

2 Answers2

6

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.

romainl
  • 186,200
  • 21
  • 280
  • 313
0

With the 2016 commit this feature was added to Vim in the gzip plugin

To view a file today within the shell, use vim file.zst

pratikpc
  • 432
  • 4
  • 12