19

I'm trying to open an .xlsx file in Vim, but got an error saying:

***error*** (zip#Browse) unzip not available on your system  

I know it's a binary file, but I want to do some checksums and probably convert to hex.

I noticed that if I change the extension, Vim no longer tries to unzip it. Which leads me to my question:

Is there a way to tell Vim to open a file without attempting to unzip it?

FWIW, I'm using Vim 7.4 under Windows 7.

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
Roflo
  • 767
  • 1
  • 8
  • 24
  • I get the same error on my Linux system, so it doesn't seem to be Windows-specific behaviour – Martin Tournoij Feb 25 '15 at 21:14
  • 1
    Just out of curiosity, why are you doing your checksums/hex from within vim? – Random832 Feb 25 '15 at 22:22
  • @Random832 on this occasion, just because it's the first thing that came to my mind. Most other times, because I can checksum a range instead of the whole file, and hex because I can switch back and forth with raw. – Roflo Feb 26 '15 at 14:52

2 Answers2

20

Functionality like this is handled by autocmds. In order to disable autocmds for a specific command, you can use :noautocmd (abbreviated :noau). In this case

:noau e foo.xlsx

will simply open the raw file rather than triggering the autocmds that try to open the zip file.

You can also use this from your shell:

$ vim -c 'noau e foo.xlsx'

If you want more granularity than disabling all autocmds, you could temporarily disable the BufRead/BufReadPre autocmds using the 'eventignore' option.

:set ei=BufRead,BufReadPre
:e foo.xlsx
:set ei=
Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
jamessan
  • 11,045
  • 2
  • 38
  • 53
  • Is it also possible to disable just the autocmd/augroup as defined by the zip plugin? I like this (+1), but if you for example have an autocmd to disable syntax highlight and such for large files (as is common), then you will also disable that as a side-effect... – Martin Tournoij Feb 25 '15 at 21:43
  • @Carpetsmoker Not temporarily. If you know the group name (in this case "zip"), you can undefine all of the autocmds defined in that group with augroup zip | exe 'au!' | augroup END. – jamessan Feb 25 '15 at 21:47
12

This seems to the the "zip" plugin, which is shipped with Vim and enabled by default.

:help zip has some information about it, among other things:

PREVENTING LOADING

If for some reason you do not wish to use vim to examine zipped files, you may put the following two variables into your <.vimrc> to prevent the zip plugin from loading:

let g:loaded_zipPlugin= 1                                               
let g:loaded_zip      = 1                                               

After adding these 2 lines, I'm able to open a .zip file as any other file.

I didn't know about this either, by the way; but the error message mentioned zip#Browse, so I just typed :help zip and landed on the right documentation page :-)

See How do I navigate to topics in Vim's documentation? for some more information & tips about Vim's help system.

This will also work for the tar plugin, except you use g:loaded_tarPlugin & g_loaded_tar.

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271