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:
- 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/vim*/plugin/gzip.vim
and its companion in/usr/share/vim/vim*/autoload/gzip.vim
.
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.
Related videos on Youtube
Author by
Ahmad
Updated on September 18, 2022Comments
-
Ahmad over 1 year
I want to see some zipped log files
.gz
in unix through putty. When I open them invim
the contents are not readable. I think vim is not able to unzip them.-
jahroy over 11 yearsVim is for text files. It does not unzip files or view compressed files.
-
Benoit over 11 years@jahroy: some vim distributions have autocmds for unzipping those files
-
Shiplu Mokaddim over 11 yearsvim is a text editor. Not zip viewer.
-
Benoit over 11 yearsAhmad, 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 over 11 years@[email protected] colleagues are able to see it..how ever they too are facing this problem sometime..
-
Admin over 11 years@Benoit..I just need to type ":autocmd?"...right?
-
Benoit over 11 years@Ahmad: type
:autocmd BufRead *.gz
and tell me whether you see what I saw (call gzip#read...) -
Admin over 11 years@Benoit..."ksh: :autocmd: not found"..I typed ":autocmd BufRead .log.gz".... being my file name
-
Shiplu Mokaddim over 11 years@Ahmad you need to type that inside vim after pressing
Esc
. Not in ksh console. -
Admin over 11 years@Benoit...it said "3 files to edit"...but it didn't show the content
-
Benoit over 11 yearsdon't type
.log.gz
but*.gz
-
-
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 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 over 11 years@Ahmad do you have read permission to read that file?
-
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 over 11 years@shiplu.mokadd.im: good remark. removing my -1.
-
Benoit over 11 yearsalso needs
autoload/gzip.vim
-
romainl over 11 yearsYou are right. I'll add it to my answer if you don't mind.
-
Ôrel over 8 yearsCan be a conflict between several plugins, for example file-line github.com/bogado/file-line/issues/56
-
Todd Walton over 4 yearsAlso, I just figured out... you can't view gzipped files with 'view', presumably because 'view' puts vim into compatible mode.