如何在 Gvim 中打开 gzip 文本文件而不解压?

发布于 2024-10-26 04:17:26 字数 47 浏览 2 评论 0原文

如何在 Gvim 中打开 Gzip 压缩的文本文件(*.gz)而不先解压缩它们?

How to open Gzipped text files (*.gz) in Gvim without unzipping them first ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

千柳 2024-11-02 04:17:26

VimDocs 中提到的解决方案为 therefromwhere 回答

augroup gzip
 autocmd!
 autocmd BufReadPre,FileReadPre *.gz set bin
 autocmd BufReadPost,FileReadPost   *.gz '[,']!gunzip
 autocmd BufReadPost,FileReadPost   *.gz set nobin
 autocmd BufReadPost,FileReadPost   *.gz execute ":doautocmd BufReadPost " . expand("%:r")
 autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
 autocmd BufWritePost,FileWritePost *.gz !gzip <afile>:r
 autocmd FileAppendPre      *.gz !gunzip <afile>
 autocmd FileAppendPre      *.gz !mv <afile>:r <afile>
 autocmd FileAppendPost     *.gz !mv <afile> <afile>:r
 autocmd FileAppendPost     *.gz !gzip <afile>:r
augroup END

Solution mentioned in VimDocs as answered by therefromwhere

augroup gzip
 autocmd!
 autocmd BufReadPre,FileReadPre *.gz set bin
 autocmd BufReadPost,FileReadPost   *.gz '[,']!gunzip
 autocmd BufReadPost,FileReadPost   *.gz set nobin
 autocmd BufReadPost,FileReadPost   *.gz execute ":doautocmd BufReadPost " . expand("%:r")
 autocmd BufWritePost,FileWritePost *.gz !mv <afile> <afile>:r
 autocmd BufWritePost,FileWritePost *.gz !gzip <afile>:r
 autocmd FileAppendPre      *.gz !gunzip <afile>
 autocmd FileAppendPre      *.gz !mv <afile>:r <afile>
 autocmd FileAppendPost     *.gz !mv <afile> <afile>:r
 autocmd FileAppendPost     *.gz !gzip <afile>:r
augroup END
满栀 2024-11-02 04:17:26

Vim 应该自动为你做这件事。至少对我来说是这样。还有zless。我会看看是否可以找到一个资源来讨论 vim 如何做到这一点。

Vim should do this for you automatically. At least it does for me. There's also zless. I'll see if I can find a resource that talks about how vim does this.

安静 2024-11-02 04:17:26

vim 文档中有一个示例,说明如何实现此功能: http://vimdoc .sourceforge.net/htmldoc/autocmd.html#gzip-example

就其价值而言,我不需要在 Ubuntu 10.04 (vim v7.2) 上执行此操作,它开箱即用。

There's a example in the vim docs how how to get this working: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#gzip-example

For what it's worth I didn't need to do this on Ubuntu 10.04 (vim v7.2), it worked out of the box.

以酷 2024-11-02 04:17:26

直接打开它们只会给你原始的二进制压缩数据。凡事都有工具,但需要正确使用它们。大锤不是用来敲鸡蛋当早餐的,文本编辑器也不是用来解压缩的。

Opening them directly would just give you the raw binary compressed data. There's tools for everything, but they need to be used appropriately. Sledgehammers are not there to break eggs for breakfast, and text editors aren't there to unzip.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文