Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

gzip

Vim automatically expands .gz files when I open them up, which is great. However, it doesn't reccognize .GZ (upper case) in the same way. Unfortunately I cannot change the file extensions of the files I'm working with for various reasons. Is there a realatively simple way to register with VIM that .GZ are the same as .gz files?

like image 791
Lowell Avatar asked Sep 16 '11 13:09

Lowell


1 Answers

Put this into 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 what autocmds were already activated for gz files you could have done:

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

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

Reference:

:help :autocmd
:help :augroup

Original autocmds are in plugin/gzip.vim in your vim runtime. You can tell that with :verbose au gzip

like image 163
Benoit Avatar answered Oct 24 '22 00:10

Benoit