viai-editor / viai-doc-ja / pi_zip

pi_zip - ViAI日本語ドキュメント

メインヘルプファイルに戻る English | 日本語 | 編集 |
pi_zip.txt    For ViAI バージョン 1.0.  Last change: 2026 Aug 19

                                +====================+
                                | Zip File Interface |
                                +====================+

Author:  Charles E. Campbell  <NcampObell@SdrPchip.AorgM-NOSPAM>
          (まず Campbell のメールアドレスから NOSPAM を削除すること)
Copyright: Copyright (C) 2005-2015 Charles E Campbell    zip-copyright
        The VIM LICENSE (see copyright) applies to the files in this
        package, including zipPlugin.vim, zip.vim, and pi_zip.vim.  except use
        "zip.vim" instead of "VIM".  Like anything else that's free, zip.vim
        and its associated files are provided *as is* and comes with no
        warranty of any kind, either expressed or implied.  No guarantees of
        merchantability.  No guarantees of suitability for any purpose.  By
        using this plugin, you agree that in no event will the copyright
        holder be liable for any damages resulting from the use of this
        software. Use at your own risk!

==============================================================================
1. 目次                                                 zip zip-contents
   1. 目次....................................................zip-contents
   2. 使い方..................................................zip-usage
   3. 追加の拡張子............................................zip-extension
   4. 履歴....................................................zip-history

==============================================================================
2. 使い方                                               zip-usage zip-manual

   *.zip ファイルを編集すると、このプラグインが内容ページの表示を処理する。編
   集するファイルは、カーソルをそのファイルの上に移動してから <return> キーを
   押して選ぶ。編集した後、そのファイルに書き込むこともできる。現在、このプラ
   グインで zip アーカイブの中に新しいファイルを作ることはできない。

   zip プラグインは、よくあるパストラバーサル攻撃のパターンをいくつか検出しよ
   うとするが、すべての場合を捕捉できるとは限らない。信頼できない入力に対して
   このプラグインを使うときは、十分に注意すること。

   コマンド
                                                                zip-x
   x : カーソルが一覧のファイルの上にあるとき、そのファイルを展開する

   オプション

                                                        g:zip_nomax

   この変数が存在し真である場合、ファイルウィンドウは開いたときに自動的に最大
   化されない。

                                                        g:zip_unzipcmd
   これらのオプションを使って、"unzip" の役目を果たすプログラム、および必要な
   引数スイッチを指定する。
   これはブラウズのときに使われる。デフォルト:
        let g:zip_unzipcmd= "unzip"
        let g:zip_unzipcmd_browseopt= "-Z1"
        let g:zip_unzipcmd_readopt= "-p"

   Note: オプションの終わりを示すため、g:zip_unzipcmd_browseopt および
   g:zip_unzipcmd_readopt の設定の後に -- が付け加えられる。

                                                        g:zip_zipcmd
   これらのオプションを使って、"zip" の役目を果たすプログラム、および必要な引
   数スイッチを指定する。
   これは、すでに zip ファイルの中にあるファイルを書き込む (更新する) ときに使
   われる。デフォルト:
        let g:zip_zipcmd= "zip"
        let g:zip_zipcmd_deleteopt= "-d"
        let g:zip_zipcmd_updateopt= "-u"

                                                        g:zip_extractcmd
   このオプションは、zip アーカイブからファイルを展開するのに使うプログラム
   (および必要なオプション) を指定する。デフォルト:
        let g:zip_extractcmd= g:zip_unzipcmd
        let g:zip_extractcmd_extractopt= "-o"

                                                        g:zip_exec
   セキュリティ上の理由から、バッファを開いたときに Vim が実行可能ファイルを自
   動的に実行するのを防ぐことができる。このオプション (デフォルト: "1") を "0"
   に設定すると、"unzip" コマンドの実行を防ぐことができる:
        let g:zip_exec=0

   POWERSHELL へのフォールバック

                                                        g:zip_pwsh
   このプラグインは、まず (より高機能な) GNU の zip/unzip コマンドを使おうとす
   る。これらのコマンドが使えないか、または失敗し、ユーザーが PowerShell を使っ
   ている場合は、プラグインは PowerShell のコマンドレットにフォールバックする。
   PowerShell のコマンドレットには制限があり、zip アーカイブのサブディレクトリ
   の中のファイルの書き込みまたは展開はできない。しかし利点は、別に unzip のバ
   イナリをインストールする必要がないことである。"pwsh" または "powershell" の
   どちらを選ぶかについて 'shell' オプションが確認される。または g:zip_pwsh
   を設定する。両方が使える場合、このプラグインは pwsh を優先する。
   "g:zip_pwsh" のデフォルト値は空文字列で、これは 'shell' オプションの設定を
   上書きしない。MS-Windows ではデフォルトの 'shell' が "cmd.exe" なので、この
   機能はデフォルトでは有効にならない。例:
        let g:zip_pwsh='powershell'

   読み込みの防止

   何らかの理由で zip されたファイルを調べるのに vim を使いたくない場合は、以
   下の 2 つの変数を <.vimrc> に入れると、zip プラグインが読み込まれるのを防ぐ
   ことができる:

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


==============================================================================
3. 追加の拡張子                                                 zip-extension

   .zip の拡張子を使わない zip ファイルを生成するアーカイバーがたくさんあるよ
   うだ (.jar、.xpi など)。このようなファイルを扱うには、<.vimrc> ファイルに 1
   行入れる:

        au BufReadCmd *.jar,*.xpi call zip#Browse(expand("<amatch>"))

   この行を拡張して、zip ファイルとして扱うべき拡張子を追加することは簡単にで
   きる。

   または、.vimrc で g:zipPlugin_ext を変更してもよい。
   現在 (2026年5月の時点で)、これが保持しているもの:

        let g:zipPlugin_ext='*.aar,*.apk,*.cbz,*.celzip,*.crtx,*.docm,*.docx,
       \ *.dotm,*.dotx,*.ear,*.epub,*.gcsx,*.glox,*.gqsx,*.ja,*.jar,*.kmz,
       \ *.odb,*.odc,*.odf,*.odg,*.odi,*.odm,*.odp,*.ods,*.odt,*.otc,*.otf,
       \ *.otg,*.oth,*.oti,*.otp,*.ots,*.ott,*.oxt,*.pkpass,*.potm,*.potx,
       \ *.ppam,*.ppsm,*.ppsx,*.pptm,*.pptx,*.sldx,*.thmx,*.vdw,*.war,*.whl,
       \ *.wsz, *.xap,*.xlam,*.xlsb,*.xlsm,*.xlsx,*.xltm,*.xltx,*.xpi,*.zip'

==============================================================================
4. 履歴                                                         zip-history {{{1
   unreleased:
       Jul 25, 2026 * support both Windows PowerShell 5 and pwsh 7+
       Sep 19, 2025 * support PowerShell Core
       Jul 12, 2025 * drop ../ on write to prevent path traversal attacks
       Mar 11, 2025 * handle filenames with leading '-' correctly
       Aug 21, 2024 * simplify condition to detect MS-Windows
       Aug 18, 2024 * correctly handle special globbing chars
       Aug 05, 2024 * clean-up and make it work with shellslash on Windows
       Aug 05, 2024 * workaround for the FreeBSD's unzip
       Aug 04, 2024 * escape '[' in name of file to be extracted
       Jul 30, 2024 * fix opening remote zipfile
       Jul 24, 2024 * use delete() function
       Jul 23, 2024 * fix 'x' command
       Jun 16, 2024 * handle whitespace on Windows properly (#14998)
   v33 Dec 07, 2021 * *.xlam mentioned twice in zipPlugin
   v32 Oct 22, 2021 * to avoid an issue with a vim 8.2 patch, zipfile: has
                      been changed to zipfile:// . This often shows up
                      as zipfile:/// with zipped files that are root-based.
   v29 Apr 02, 2017 * (Klartext) reported that an encrypted zip file could
                      opened but the swapfile held unencrypted contents.
                      The solution is to edit the contents of a zip file
                      using the :noswapfile modifier.
   v28 Oct 08, 2014 * changed the sanity checks for executables to reflect
                      the command actually to be attempted in zip#Read()
                      and zip#Write()
                    * added the extraction of a file capability
       Nov 30, 2015 * added *.epub to the g:zipPlugin_ext list
       Sep 13, 2016 * added *.apk to the g:zipPlugin_ext list and
                      sorted the suffices.
   v27 Jul 02, 2013 * sanity check: zipfile must have "PK" as its first
                      two bytes.
                    * modified to allow zipfile: entries in quickfix lists
   v26 Nov 15, 2012 * (Jason Spiro) provided a lot of new extensions that
                      are synonyms for .zip
   v25 Jun 27, 2011 * using keepj with unzip -Z
                      (consistent with the -p variant)
                    * (Ben Staniford) now uses
                        has("win32unix") && executable("cygpath")
                      before converting to cygwin-style paths
   v24 Jun 21, 2010 * (Cédric Bosdonnat) unzip seems to need its filenames
                      fnameescape'd as well as shellquote'd
                    * (Motoya Kurotsu) inserted keepj before 0d to protect
                      jump list
   v17 May 09, 2008 * arno caught a security bug
   v15 Sep 07, 2007 * &shq now used if not the empty string for g:zip_shq
   v14 May 07, 2007 * using b:zipfile instead of w:zipfile to avoid problem
                      when editing alternate file to bring up a zipfile
   v10 May 02, 2006 * now using "redraw then echo" to show messages, instead
                      of "echo and prompt user"
                    * g:zip_shq provided to allow for quoting control for the
                      command being passed via :r! ... commands.
   v8 Apr 10, 2006 * Bram Moolenaar reported that he received an error message
                     due to "Pattern not found: ^.*\%0c"; this was caused by
                     stridx finding a Name... at the beginning of the line;
                     zip.vim tried 4,$s/^.*\%0c//, but that doesn't work.
                     Fixed.
   v7 Mar 22, 2006 * escaped some characters that can cause filename handling
                     problems.
   v6 Dec 21, 2005 * writing to files not in directories caused problems -
                     fixed (pointed out by Christian Robinson)
   v5 Nov 22, 2005 * report option workaround installed
   v3 Oct 18, 2005 * <amatch> used instead of <afile> in autocmds
   v2 Sep 16, 2005 * silenced some commands (avoiding hit-enter prompt)
                   * began testing under Windows; works thus far
                   * filetype detection fixed
      Nov 03, 2005 * handles writing zipfiles across a network using
                     netrw#NetWrite()
   v1 Sep 15, 2005 * Initial release, had browsing, reading, and writing

==============================================================================
vim:tw=78:ts=8:ft=help:noet:norl:fdm=marker