Christian Brabandt | 8293574 | 2025-04-02 20:26:38 +0200 | [diff] [blame] | 1 | *pi_zip.txt* For Vim version 9.1. Last change: 2025 Apr 02 |
Bram Moolenaar | c01140a | 2006-03-24 22:21:52 +0000 | [diff] [blame] | 2 | |
Bram Moolenaar | 910f66f | 2006-04-05 20:41:53 +0000 | [diff] [blame] | 3 | +====================+ |
| 4 | | Zip File Interface | |
| 5 | +====================+ |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 6 | |
Bram Moolenaar | 2963456 | 2020-01-09 21:46:04 +0100 | [diff] [blame] | 7 | Author: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM> |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 8 | (remove NOSPAM from Campbell's email first) |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 9 | Copyright: Copyright (C) 2005-2015 Charles E Campbell *zip-copyright* |
Bram Moolenaar | 6be7f87 | 2012-01-20 21:08:56 +0100 | [diff] [blame] | 10 | The VIM LICENSE (see |copyright|) applies to the files in this |
| 11 | package, including zipPlugin.vim, zip.vim, and pi_zip.vim. except use |
| 12 | "zip.vim" instead of "VIM". Like anything else that's free, zip.vim |
| 13 | and its associated files are provided *as is* and comes with no |
| 14 | warranty of any kind, either expressed or implied. No guarantees of |
| 15 | merchantability. No guarantees of suitability for any purpose. By |
| 16 | using this plugin, you agree that in no event will the copyright |
| 17 | holder be liable for any damages resulting from the use of this |
| 18 | software. Use at your own risk! |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 19 | |
| 20 | ============================================================================== |
Bram Moolenaar | 251e191 | 2011-06-19 05:09:16 +0200 | [diff] [blame] | 21 | 1. Contents *zip* *zip-contents* |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 22 | 1. Contents................................................|zip-contents| |
| 23 | 2. Usage...................................................|zip-usage| |
| 24 | 3. Additional Extensions...................................|zip-extension| |
| 25 | 4. History.................................................|zip-history| |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 26 | |
| 27 | ============================================================================== |
Bram Moolenaar | 251e191 | 2011-06-19 05:09:16 +0200 | [diff] [blame] | 28 | 2. Usage *zip-usage* *zip-manual* |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 29 | |
| 30 | When one edits a *.zip file, this plugin will handle displaying a |
| 31 | contents page. Select a file to edit by moving the cursor atop |
| 32 | the desired file, then hit the <return> key. After editing, one may |
| 33 | also write to the file. Currently, one may not make a new file in |
| 34 | zip archives via the plugin. |
| 35 | |
Bram Moolenaar | 2963456 | 2020-01-09 21:46:04 +0100 | [diff] [blame] | 36 | COMMANDS~ |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 37 | *zip-x* |
Bram Moolenaar | 2963456 | 2020-01-09 21:46:04 +0100 | [diff] [blame] | 38 | x : extract a listed file when the cursor is atop it |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 39 | |
Bram Moolenaar | 2963456 | 2020-01-09 21:46:04 +0100 | [diff] [blame] | 40 | OPTIONS~ |
Bram Moolenaar | 3577c6f | 2008-06-24 21:16:56 +0000 | [diff] [blame] | 41 | |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 42 | *g:zip_nomax* |
Bram Moolenaar | 3577c6f | 2008-06-24 21:16:56 +0000 | [diff] [blame] | 43 | |
| 44 | If this variable exists and is true, the file window will not be |
| 45 | automatically maximized when opened. |
| 46 | |
| 47 | *g:zip_shq* |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 48 | Different operating systems may use one or more shells to execute |
| 49 | commands. Zip will try to guess the correct quoting mechanism to |
| 50 | allow spaces and whatnot in filenames; however, if it is incorrectly |
| 51 | guessing the quote to use for your setup, you may use > |
| 52 | g:zip_shq |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 53 | < which by default is a single quote under Unix (') and a double quote |
| 54 | under Windows ("). If you'd rather have no quotes, simply set |
| 55 | g:zip_shq to the empty string (let g:zip_shq= "") in your <.vimrc>. |
| 56 | |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 57 | *g:zip_unzipcmd* |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 58 | Use this option to specify the program which does the duty of "unzip". |
Bram Moolenaar | 3577c6f | 2008-06-24 21:16:56 +0000 | [diff] [blame] | 59 | It's used during browsing. By default: > |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 60 | let g:zip_unzipcmd= "unzip" |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 61 | < |
| 62 | *g:zip_zipcmd* |
| 63 | Use this option to specify the program which does the duty of "zip". |
Bram Moolenaar | 3577c6f | 2008-06-24 21:16:56 +0000 | [diff] [blame] | 64 | It's used during the writing (updating) of a file already in a zip |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 65 | file; by default: > |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 66 | let g:zip_zipcmd= "zip" |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 67 | < |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 68 | *g:zip_extractcmd* |
| 69 | This option specifies the program (and any options needed) used to |
| 70 | extract a file from a zip archive. By default, > |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 71 | let g:zip_extractcmd= g:zip_unzipcmd |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 72 | < |
Christian Brabandt | da4e433 | 2023-11-05 10:45:12 +0100 | [diff] [blame] | 73 | *g:zip_exec* |
| 74 | For security reasons, one may prevent that Vim runs executables |
| 75 | automatically when opening a buffer. This option (default: "1") |
| 76 | can be used to prevent executing the "unzip" command when set to |
| 77 | "0": > |
| 78 | let g:zip_exec=0 |
| 79 | < |
Bram Moolenaar | 00a927d | 2010-05-14 23:24:24 +0200 | [diff] [blame] | 80 | PREVENTING LOADING~ |
| 81 | |
| 82 | If for some reason you do not wish to use vim to examine zipped files, |
| 83 | you may put the following two variables into your <.vimrc> to prevent |
Bram Moolenaar | 24ea3ba | 2010-09-19 19:01:21 +0200 | [diff] [blame] | 84 | the zip plugin from loading: > |
Bram Moolenaar | 00a927d | 2010-05-14 23:24:24 +0200 | [diff] [blame] | 85 | |
| 86 | let g:loaded_zipPlugin= 1 |
| 87 | let g:loaded_zip = 1 |
| 88 | < |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 89 | |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 90 | ============================================================================== |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 91 | 3. Additional Extensions *zip-extension* |
| 92 | |
Bram Moolenaar | 6be7f87 | 2012-01-20 21:08:56 +0100 | [diff] [blame] | 93 | Apparently there are a number of archivers which generate zip files that |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 94 | don't use the .zip extension (.jar, .xpi, etc). To handle such files, |
| 95 | place a line in your <.vimrc> file: > |
| 96 | |
| 97 | au BufReadCmd *.jar,*.xpi call zip#Browse(expand("<amatch>")) |
| 98 | < |
Bram Moolenaar | c236c16 | 2008-07-13 17:41:49 +0000 | [diff] [blame] | 99 | One can simply extend this line to accommodate additional extensions that |
Bram Moolenaar | 3577c6f | 2008-06-24 21:16:56 +0000 | [diff] [blame] | 100 | should be treated as zip files. |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 101 | |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 102 | Alternatively, one may change *g:zipPlugin_ext* in one's .vimrc. |
Christian Brabandt | 8293574 | 2025-04-02 20:26:38 +0200 | [diff] [blame] | 103 | Currently (as of April 2025) it holds: > |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 104 | |
Christian Brabandt | 8293574 | 2025-04-02 20:26:38 +0200 | [diff] [blame] | 105 | let g:zipPlugin_ext='*.aar,*.apk,*.celzip,*.crtx,*.docm,*.docx, |
| 106 | \ *.dotm,*.dotx,*.ear,*.epub,*.gcsx,*.glox,*.gqsx,*.ja,*.jar,*.kmz, |
| 107 | \ *.odb,*.odc,*.odf,*.odg,*.odi,*.odm,*.odp,*.ods,*.odt,*.otc,*.otf, |
| 108 | \ *.otg,*.oth,*.oti,*.otp,*.ots,*.ott,*.oxt,*.potm,*.potx,*.ppam, |
Christian Brabandt | a359c9c | 2025-04-02 20:42:58 +0200 | [diff] [blame] | 109 | \ *.ppsm,*.ppsx,*.pptm,*.pptx,*.sldx,*.thmx,*.vdw,*.war,*.whl,*.wsz, |
| 110 | \ *.xap,*.xlam,*.xlsb,*.xlsm,*.xlsx,*.xltm,*.xltx,*.xpi,*.zip' |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 111 | |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 112 | ============================================================================== |
Bram Moolenaar | 251e191 | 2011-06-19 05:09:16 +0200 | [diff] [blame] | 113 | 4. History *zip-history* {{{1 |
Bram Moolenaar | 71badf9 | 2023-04-22 22:40:14 +0100 | [diff] [blame] | 114 | v33 Dec 07, 2021 * *.xlam mentioned twice in zipPlugin |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 115 | v32 Oct 22, 2021 * to avoid an issue with a vim 8.2 patch, zipfile: has |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 116 | been changed to zipfile:// . This often shows up |
Bram Moolenaar | 519cc55 | 2021-11-16 19:18:26 +0000 | [diff] [blame] | 117 | as zipfile:/// with zipped files that are root-based. |
Bram Moolenaar | 2963456 | 2020-01-09 21:46:04 +0100 | [diff] [blame] | 118 | v29 Apr 02, 2017 * (Klartext) reported that an encrypted zip file could |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 119 | opened but the swapfile held unencrypted contents. |
Bram Moolenaar | 2963456 | 2020-01-09 21:46:04 +0100 | [diff] [blame] | 120 | The solution is to edit the contents of a zip file |
| 121 | using the |:noswapfile| modifier. |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 122 | v28 Oct 08, 2014 * changed the sanity checks for executables to reflect |
Bram Moolenaar | 6ebe4f9 | 2022-10-28 20:47:54 +0100 | [diff] [blame] | 123 | the command actually to be attempted in zip#Read() |
Bram Moolenaar | d079690 | 2016-09-16 20:02:31 +0200 | [diff] [blame] | 124 | and zip#Write() |
| 125 | * added the extraction of a file capability |
| 126 | Nov 30, 2015 * added *.epub to the |g:zipPlugin_ext| list |
| 127 | Sep 13, 2016 * added *.apk to the |g:zipPlugin_ext| list and |
| 128 | sorted the suffices. |
| 129 | v27 Jul 02, 2013 * sanity check: zipfile must have "PK" as its first |
| 130 | two bytes. |
| 131 | * modified to allow zipfile: entries in quickfix lists |
Bram Moolenaar | ff03419 | 2013-04-24 18:51:19 +0200 | [diff] [blame] | 132 | v26 Nov 15, 2012 * (Jason Spiro) provided a lot of new extensions that |
| 133 | are synonyms for .zip |
Bram Moolenaar | 6be7f87 | 2012-01-20 21:08:56 +0100 | [diff] [blame] | 134 | v25 Jun 27, 2011 * using keepj with unzip -Z |
| 135 | (consistent with the -p variant) |
Bram Moolenaar | ff03419 | 2013-04-24 18:51:19 +0200 | [diff] [blame] | 136 | * (Ben Staniford) now uses |
| 137 | has("win32unix") && executable("cygpath") |
| 138 | before converting to cygwin-style paths |
Bram Moolenaar | 251e191 | 2011-06-19 05:09:16 +0200 | [diff] [blame] | 139 | v24 Jun 21, 2010 * (Cédric Bosdonnat) unzip seems to need its filenames |
| 140 | fnameescape'd as well as shellquote'd |
| 141 | * (Motoya Kurotsu) inserted keepj before 0d to protect |
| 142 | jump list |
Bram Moolenaar | 3577c6f | 2008-06-24 21:16:56 +0000 | [diff] [blame] | 143 | v17 May 09, 2008 * arno caught a security bug |
| 144 | v15 Sep 07, 2007 * &shq now used if not the empty string for g:zip_shq |
Bram Moolenaar | 7263a77 | 2007-05-10 17:35:54 +0000 | [diff] [blame] | 145 | v14 May 07, 2007 * using b:zipfile instead of w:zipfile to avoid problem |
| 146 | when editing alternate file to bring up a zipfile |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 147 | v10 May 02, 2006 * now using "redraw then echo" to show messages, instead |
| 148 | of "echo and prompt user" |
| 149 | * g:zip_shq provided to allow for quoting control for the |
| 150 | command being passed via :r! ... commands. |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 151 | v8 Apr 10, 2006 * Bram Moolenaar reported that he received an error message |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 152 | due to "Pattern not found: ^.*\%0c"; this was caused by |
Bram Moolenaar | 4c3f536 | 2006-04-11 21:38:50 +0000 | [diff] [blame] | 153 | stridx finding a Name... at the beginning of the line; |
| 154 | zip.vim tried 4,$s/^.*\%0c//, but that doesn't work. |
| 155 | Fixed. |
Bram Moolenaar | 7b5f832 | 2006-03-23 22:47:08 +0000 | [diff] [blame] | 156 | v7 Mar 22, 2006 * escaped some characters that can cause filename handling |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 157 | problems. |
Bram Moolenaar | 86e0108 | 2005-12-29 22:45:34 +0000 | [diff] [blame] | 158 | v6 Dec 21, 2005 * writing to files not in directories caused problems - |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 159 | fixed (pointed out by Christian Robinson) |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 160 | v5 Nov 22, 2005 * report option workaround installed |
| 161 | v3 Oct 18, 2005 * <amatch> used instead of <afile> in autocmds |
| 162 | v2 Sep 16, 2005 * silenced some commands (avoiding hit-enter prompt) |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 163 | * began testing under Windows; works thus far |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 164 | * filetype detection fixed |
| 165 | Nov 03, 2005 * handles writing zipfiles across a network using |
Bram Moolenaar | 9964e46 | 2007-05-05 17:54:07 +0000 | [diff] [blame] | 166 | netrw#NetWrite() |
Bram Moolenaar | 9835862 | 2005-11-28 22:58:23 +0000 | [diff] [blame] | 167 | v1 Sep 15, 2005 * Initial release, had browsing, reading, and writing |
| 168 | |
| 169 | ============================================================================== |
Bram Moolenaar | cb80aa2 | 2020-10-26 21:12:46 +0100 | [diff] [blame] | 170 | vim:tw=78:ts=8:ft=help:noet:norl:fdm=marker |