Can VIM unzip gzip files automatically with a different file extension?

Vim automatically expands .gz files when I open them, which is great. However, it will not ignore .gz (upper case) in the same way. Unfortunately, I cannot change the file extensions of the files that I work with for various reasons. Is there an easy way to register with VIM that .gz matches with .gz files?

+8
vim gz
source share
1 answer

Put this in your .vimrc:

  augroup gzip au BufReadPre *.GZ setlocal bin au BufRead *.GZ call gzip#read("gzip -dn") au BufWritePost *.GZ call gzip#write("gzip") au FileAppendPost *.GZ call gzip#write("gzip") au FileAppendPre *.GZ call gzip#appre("gzip -dn") au FileReadPost *.GZ call gzip#read("gzip -dn") au FileReadPre *.GZ setlocal bin au FileWritePost *.GZ call gzip#write("gzip") augroup END 

If you want to know which autocmds have already been activated for gz files, you could do:

 :redir @x :au :redir END "xp /\.gz 

This shows that gzip-related auto-locks are in the gzip group. Then :au gzip gives a more compact list.

Link:

 :help :autocmd :help :augroup 

The original autocmds are in the /gzip.vim plugin in your vim runtime. You can say that with :verbose au gzip

+10
source share

All Articles