Vim is not reading gzipped files automatically

13,810

Solution 1

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

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

Solution 2

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:
13,810

Related videos on Youtube

Ahmad
Author by

Ahmad

Updated on September 18, 2022

Comments

  • Ahmad
    Ahmad over 1 year

    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.

    • jahroy
      jahroy over 11 years
      Vim is for text files. It does not unzip files or view compressed files.
    • Benoit
      Benoit over 11 years
      @jahroy: some vim distributions have autocmds for unzipping those files
    • Shiplu Mokaddim
      Shiplu Mokaddim over 11 years
      vim is a text editor. Not zip viewer.
    • Benoit
      Benoit over 11 years
      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?
    • Admin
      Admin over 11 years
      @[email protected] colleagues are able to see it..how ever they too are facing this problem sometime..
    • Admin
      Admin over 11 years
      @Benoit..I just need to type ":autocmd?"...right?
    • Benoit
      Benoit over 11 years
      @Ahmad: type :autocmd BufRead *.gz and tell me whether you see what I saw (call gzip#read...)
    • Admin
      Admin over 11 years
      @Benoit..."ksh: :autocmd: not found"..I typed ":autocmd BufRead .log.gz".... being my file name
    • Shiplu Mokaddim
      Shiplu Mokaddim over 11 years
      @Ahmad you need to type that inside vim after pressing Esc. Not in ksh console.
    • Admin
      Admin over 11 years
      @Benoit...it said "3 files to edit"...but it didn't show the content
    • Benoit
      Benoit over 11 years
      don't type .log.gz but *.gz
  • Benoit
    Benoit over 11 years
    -1. vim with some autocmds, in some distributions, automatically gunzips the file at loading time and gzips them back before saving.
  • fer.marino
    fer.marino over 11 years
    +1. your suggestion are quite a help.. I want to see why its not working on my machine but works for others
  • Shiplu Mokaddim
    Shiplu Mokaddim over 11 years
    @Ahmad do you have read permission to read that file?
  • Shiplu Mokaddim
    Shiplu Mokaddim over 11 years
    @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.
  • Benoit
    Benoit over 11 years
    @shiplu.mokadd.im: good remark. removing my -1.
  • Benoit
    Benoit over 11 years
    also needs autoload/gzip.vim
  • romainl
    romainl over 11 years
    You are right. I'll add it to my answer if you don't mind.
  • Ôrel
    Ôrel over 8 years
    Can be a conflict between several plugins, for example file-line github.com/bogado/file-line/issues/56
  • Todd Walton
    Todd Walton over 4 years
    Also, I just figured out... you can't view gzipped files with 'view', presumably because 'view' puts vim into compatible mode.