Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to see some zipped log files .gz in unix through putty. When I open them in vim the contents are not readable. I think vim is not able to unzip them.

share|improve this question

migrated from stackoverflow.com Nov 20 '12 at 22:18

This question came from our site for professional and enthusiast programmers.

Vim is for text files. It does not unzip files or view compressed files. –  jahroy Nov 20 '12 at 9:15
@jahroy: some vim distributions have autocmds for unzipping those files –  Benoit Nov 20 '12 at 9:15
vim is a text editor. Not zip viewer. –  Shiplu Nov 20 '12 at 9:15
Ahmad, can you tell us what vim says when you type :autocmd? Is there anything about .gz files? I for example have :autocmd BufRead *.gz call gzip#read("gzip -dn"). Do you have gzip executable, and this autocmd? –  Benoit Nov 20 '12 at 9:16
@Ahmad you need to type that inside vim after pressing Esc. Not in ksh console. –  Shiplu Nov 20 '12 at 9:31

3 Answers 3

up vote 5 down vote accepted

Vim is perfectly able to open gzipped files by default, see :help gzip.

If it's not possible in your case, you should see:

  • if the machine has the gzip program,
  • if you have the right permissions to use it,
  • if your Vim comes with the the gzip standard plugin which should be located at /usr/share/vim/vim7x/plugin/gzip.vim and its companion in /usr/share/vim/vim7x/autoload/gzip.vim.
share|improve this answer
also needs autoload/gzip.vim –  Benoit Nov 20 '12 at 9:44
You are right. I'll add it to my answer if you don't mind. –  romainl Nov 20 '12 at 9:45

Reading compressed files transparently is handled by the gzip vim plugin. This plugin is only enabled when vim is not in "compatible" mode (see :help compatible for more details). An easy way to ensure "compatible" is not set, is to create an empty .vimrc file in your home directory.

share|improve this answer

Vim is used for text editing. It can not open zip files.

I want to see some zipped log files .gz in unix through putty.

To see .gz file contents in command line use this command.

 zless /path/to/file.gz

If zless is not available use gunzip and less with a pipe

gunzip -c /path/to/file.gz | less
share|improve this answer
-1. vim with some autocmds, in some distributions, automatically gunzips the file at loading time and gzips them back before saving. –  Benoit Nov 20 '12 at 9:19
+1. your suggestion are quite a help.. I want to see why its not working on my machine but works for others –  Ahmad Nov 20 '12 at 9:23
@Ahmad do you have read permission to read that file? –  Shiplu Nov 20 '12 at 9:24
@Benoit OP said I want to see some zipped log files .gz in unix through putty. And this is the answer. Besides, to only read something using vim is bad idea. –  Shiplu Nov 20 '12 at 9:25
@shiplu.mokadd.im: good remark. removing my -1. –  Benoit Nov 20 '12 at 9:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.