diff --git a/doc/quickfix.jax b/doc/quickfix.jax index adcbcdafb..de0a264dd 100644 --- a/doc/quickfix.jax +++ b/doc/quickfix.jax @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim バージョン 9.2. Last change: 2026 May 28 +*quickfix.txt* For Vim バージョン 9.2. Last change: 2026 Sep 14 VIM リファレンスマニュアル by Bram Moolenaar @@ -41,23 +41,29 @@ quickfixコマンドはより一般的に、ファイル中の位置のリスト Vim の中でコマンドを実行し結果を得る方法の一つに|:make|コマンドがある (後述)。 各コンパイラからのエラーメッセージを解釈させるためには、オプション -'errorformat' をセットする (下の|errorformat|を参照)。 +'errorformat' をセットする (下の|errorformat|を参照)。Vim はこれを使用して、コ +ンパイラの出力の各行からファイル名、行番号、メッセージなどの情報を抽出する。パ +ターンに一致しない行は無効なエントリとして保持され、|:cnext| などのコマンドで +はスキップされる。それらも表示するには |:clist|! を使用する。 *quickfix-stack* *quickfix-ID* *E1545* 各 quickfix リストは quickfix ID と呼ばれる一意な識別子を持ち、この番号は Vim セッションの中で変わらない。|getqflist()| 関数はリストに割り当てられた識別子の -取得に使用できる。quickfix リスト番号もある。この番号は、'chistory' 個以上のリ -ストが quickfix スタックに追加されるたびに変更される可能性がある。 +取得に使用できる。quickfix リストには番号もあり、これは quickfix スタック内で +の位置を表す。この番号は、リストが追加・削除されたり、保持されるリストの数が +'chistory' の上限を超えたりした際に変化する可能性がある。スクリプトから確実に +同じリストを参照する必要がある場合は ID を使用し、スタック内での現在の位置を参 +照する場合はリスト番号を使用する。 *location-list* *E776* -locationリストはウィンドウローカルなquickfixリストである。`:vimgrep`, `:grep`, -`:helpgrep`, `:make` などのコマンドはquickfixリストを作成するが、それらに対応 -する `:lvimgrep`, `:lgrep`, `:lhelpgrep`, `:lmake` などのコマンドを使うことで -locationリストを得ることができる。 +location リストは、特定のウィンドウに紐付けられた quickfix リストである。各ウィ +ンドウは個別の location リストを持つことができ、`:lvimgrep`、`:lgrep`、 +`:lhelpgrep`、`:lmake` といったコマンドは、グローバルな quickfix リストの代わ +りにこれを使用する。一方、"l" のプリフィックスが付かない対応コマンドは、 +quickfix リストを使用する。 *location-list-file-window* -locationリストはウィンドウに関連付けられていて、各ウィンドウが別々のlocationリ -ストを持つことができる。locationリストは1個のウィンドウにだけ関連付けることが -できる。locationリストはquickfixリストとは独立している。 +location リストは quickfix リストとは独立している。location リストは、1 つの +ウィンドウにのみ関連付けることができる。 locationリストを持つウィンドウが分割されると、新しいウィンドウはlocationリスト のコピーを得る。locationリストへの参照が全てなくなると、そのlocationリストは破 @@ -98,19 +104,25 @@ locationリストが |autocommand| に変更される場合、それは中断さ :[nr]ll[!] ウのlocationリストが使われる。 *:cn* *:cne* *:cnext* *E553* -:[count]cn[ext][!] ファイル名を含むエラーリストで[count]個後のエラーを表 - 示する。ファイル名が無かった場合[count]個後のエラーに - 移動する。[!]と 'switchbuf' については|:cc|を参照。 +:[count]cn[ext][!] リスト内で、ファイル名を含む次のエラーへ [count] 回移 + 動して表示する。ファイル名が含まれない項目は、それらを + 使ってファイルへジャンプすることができないため、スキッ + プされる。ファイル名が 1 つも含まれない場合は、単に次 + のエラーへ [count] 回移動する。[!] および 'switchbuf' + については |:cc| を参照。 + +:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext* +:[count]cp[revious][!] ファイル名を含むリスト内の、[count] 個前のエラーを表示 + する。ファイル名が含まれない項目は、Vim がそれらを使っ + てファイルへジャンプすることができないため、スキップさ + れる。ファイル名が 1 つも含まれない場合は、[count] 個 + 前のエラーに移動する。[!] および 'switchbuf' について + は |:cc| を参照。 *:lne* *:lnext* :[count]lne[xt][!] ":cnext" と同様だが、quickfixリストでなくカレントウィ ンドウのlocationリストが使われる。 -:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext* -:[count]cp[revious][!] ファイル名を含むエラーリストで[count]個前のエラーを表 - 示する。ファイル名が無かった場合[count]個前のエラーに - 移動する。[!]と 'switchbuf' については|:cc|を参照。 - :[count]lN[ext][!] *:lp* *:lprevious* *:lprev* *:lN* *:lNext* :[count]lp[revious][!] ":cNext" と ":cprevious" と同様だが、quickfixリストで なく、カレントウィンドウのlocationリストが使われる。 @@ -220,9 +232,10 @@ locationリストが |autocommand| に変更される場合、それは中断さ ンドを起動しない、など。 {N} を 0 にすることもできる。その場合はVimは通常終了す る。 - 警告: ファイルに対する変更はすべて失われる ([!] を指定 - しなくても)! このコマンドは、システムへの戻り値が非零 - であるということ以外 ":qall!" |:qall| と同じである。 + 警告: |:qall|! と同様に、すべてのファイルの変更を破棄 + する。 + [!] を付けてもこの動作は変わらない。{N} が 0 の場合 + を除き、Vim は 0 以外の終了コードを返す。 *:cf* *:cfi* *:cfile* :cf[ile][!] [errorfile] エラーファイルを読みこみ最初のエラーへ移動する。Vimが @@ -265,14 +278,20 @@ locationリストが |autocommand| に変更される場合、それは中断さ :laddf[ile] [errorfile] ":caddfile" と同様だが、quickfixリストでなく、カレント ウィンドウのlocationリストが使われる。 +以下のコマンドは、バッファからエラーメッセージを読み込む: +`:cbuffer` はリストを作成して最初のエラーへジャンプし、`:cgetbuffer` はジャン +プせずにリストを作成し、`:caddbuffer` はカーソル位置を変更せずに現在のリストに +エントリを追加する。先頭に "l" が付く対応するコマンドは、location リストを使用 +する。 *:cb* *:cbuffer* *E681* :[range]cb[uffer][!] [bufnr] カレントバッファからエラーリストを読み込む。[bufnr] を 指定すると、カレントバッファの代わりにそのバッファが使 われる。bufnrには読み込まれているバッファ番号を指定し - なければならない。範囲を指定すると、読み込む行を指定す - ることができる。範囲指定がないとバッファ全体が使われ - る。 + なければならない。 + 使用する行の範囲を指定することができる。例: + `:10,20cbuffer`。指定しない場合は、バッファ内のすべて + の行が使用される。 [!]については|:cc|を参照。 *:lb* *:lbuffer* @@ -302,6 +321,11 @@ locationリストが |autocommand| に変更される場合、それは中断さ ":caddbuffer" と同様だが、quickfixリストでなく、カレン トウィンドウのlocationリストが使われる。 +以下のコマンドは、式から quickfix リストを作成または更新する: +`:cexpr` はリストを作成して最初のエラーへジャンプし、`:cgetexpr` はジャンプせ +ずにリストを作成し、`:caddexpr` はカーソル位置を変更せずに現在のリストに項目を +追加する。先頭に"l" が付く対応するコマンドは、location リストを使用する。 + *:cex* *:cexpr* *E777* :cex[pr][!] {expr} {expr} の結果を使って quickfix リストを作成し、最初の エラーにジャンプする。 @@ -350,6 +374,8 @@ locationリストが |autocommand| に変更される場合、それは中断さ quickfixのエントリだけを表示するために使用できる。パ ターンは、エントリのファイル名、モジュール名、パターン およびテキストと照合される。 + 例えば、`:filter /\.c:/clist` は、表示テキストに `.c:` + を含むエントリのみを一覧表示する。|:filter| を参照。 :cl[ist] +{count} カレントと次の {count} 個の有効なエラーをリストする。 これは ":clist from from+count" に似ており、"from" は @@ -396,7 +422,7 @@ quickfixコマンド (':make', ':grep' など) を実行する前後に2つの call setqflist(qflist) endfunction - au QuickfixCmdPost make call QfMakeConv() + au QuickFixCmdPost make call QfMakeConv() 代わりに 'makeencoding' オプションを使うこともできる。 *quickfix-title* @@ -460,6 +486,20 @@ quickfixリストとlocationリストの中の項目の数をそれぞれ |getqf echo getqflist({'efm' : '%f#%l#%m', 'lines' : ['F1#10#Line']}) < +リスト内のエントリやファイルに対してコマンドを実行するには、以下を使用する: + + Quickfix list Location list + 各エントリ :cdo :ldo + 各ファイル :cfdo :lfdo + +有効な各エントリに対してコマンドを実行する必要がある場合は `:cdo` を使用する。 +例えば、マッチする各行を変更する `:cdo s/old/new/g` など。ファイルごとに 1 回 +実行する必要がある場合は `:cfdo` を使用する。例えば、影響を受ける各ファイルを +1 回書き込む `:cfdo update` など。代わりに location リストを使用するには、プリ +フィックス "l" を付ける。 + +以下のコマンドは、これらの違いをより詳細に説明している。 + ☆quickfix または location リスト中のバッファに対してコマンドを実行: *:cdo* :cdo[!] {cmd} quickfix リスト中の有効な各項目に対して {cmd} を実行す @@ -634,8 +674,10 @@ quickfixウィンドウには各行に1個ずつエラーが表示される。 まず、そのウィンドウが破棄してもよいバッファを含んでいることを確かめなければな らない。 -quickfixウィンドウからファイルを選択する場合、ファイルを編集するウィンドウを見 -付けるため次の手順が使用される: +Quickfix ウィンドウからファイルを選択すると、Vim はまず、そのファイルをすでに +表示しているウィンドウを再利用する。そうでない場合は、現在のタブページ内の適切 +なウィンドウを使用するか、新しいウィンドウを開く。選択に関する詳細なルールは以 +下の通りである: 1. 選択されたファイルを表示するウィンドウがカレントタブページに存在する場合 (quickfixウィンドウの前のウィンドウから探し始める)、そのウィンドウが使用さ @@ -653,6 +695,16 @@ quickfixウィンドウからファイルを選択する場合、ファイルを 6. 上記の手順が失敗した場合、quickfixウィンドウの上に水平方向に分割された新し いウィンドウが使用される。 + *quickfix-winfixbuf* +エラーを表示する予定のウィンドウに 'winfixbuf' が設定されている場合、そのウィ +ンドウ内で別のバッファにあるエラーへジャンプすることはできません。quickfix リ +ストの場合、Vim は代わりに適切なウィンドウを探す。具体的には、直前に使用してい +たウィンドウに 'winfixbuf' が設定されていなければそれを使用し、設定されていれ +ば新しいウィンドウを分割して作成する。location リストの場合は |E1513| エラーと +なり失敗する。これは、location リストが特定のウィンドウに結び付けられており、 +別のウィンドウへ移動したり、そこから新しいウィンドウを分割したりすることができ +ないためである。[!] を使用すると、これらのチェックはスキップされる。 + *CTRL-W_* *CTRL-W_* CTRL-W を使うと、新しいウィンドウを開いてそこでエラーにジャンプできる。 @@ -684,8 +736,10 @@ locationリストウィンドウはlocationリストの中身を表示する。l のlocationリストウィンドウを開ける点が異なる。このウィンドウ内でlocationリスト コマンドを使うと、表示されているlocationリストが使われる。 -locationリストウィンドウからファイルを選択する場合、ファイルを編集するウィンド -ウを見付けるため次の手順が使用される: +location リストウィンドウからファイルを選択すると、Vim はまず、可能な限りその +location リストに関連付けられたウィンドウを使用する。それができない場合は、適 +切なウィンドウを再利用するか、新しいウィンドウを開く。選択に関する詳細なルール +は以下の通り: 1. locationリストに紐付いているquickfix以外のウィンドウがカレントタブページに 存在する場合、そのウィンドウが使われる。 @@ -913,6 +967,13 @@ quickfixやlocationリストのスタック数を取得するには、特別な ":make" と同様だが、quickfixリストでなく、カレントウィ ンドウのlocationリストが使われる。 +要するに、`:make` は 'makeprg' を実行し、'errorformat' を使ってその出力を読み +込み、必要に応じて最初に認識されたエラー箇所へジャンプした後、通常の `:make` +の処理手順で使用された一時的なエラーファイルを削除する。'shellpipe' が空である +場合や、プログラム自身が出力ファイルを管理している場合、そのプログラムのファイ +ルに対してはこの削除処理は行われない。生成されたリストを移動するには、|:cnext| +などの関連コマンドを使用する。 + コマンド ":make" はオプション 'makeprg' で与えられるコマンドを実行する。これは オプション 'shell' で与えられたシェルにコマンドを渡す事で実行されている。以下 をタイピングするのとほぼ同じである。 @@ -962,7 +1023,7 @@ QuickFixCmdPost を使ってエンコーディングを修正する ~ call setqflist(qflist) endfunction - au QuickfixCmdPost make call QfMakeConv() + au QuickFixCmdPost make call QfMakeConv() (Faque Cheng による例) 代わりに 'makeencoding' オプションを使うこともできる。 @@ -974,7 +1035,9 @@ Vimにはパターンを検索する方法が2つある: 内部grepと外部grep 点は、全てのシステム上で動作し、Vimの強力な検索パターンを使えることである。内 部grepが目的に合わない場合は外部grepを使うことができる。 -内部grepはファイルをメモリに読み込むため、より遅い。利点は: +内部メソッドはファイルをメモリに読み込むため、処理が遅くなる。大規模なプロジェ +クトでは、外部の検索プログラムと組み合わせた |:grep| の使用を検討すること。内 +部メソッドの利点は以下の通りである: - ファイルを開くときと同様に改行コードとエンコーディングが自動的に認識される。 - Vimの検索パターンを使う。複数行にわたるパターンが使える。 - プラグインが有効になっていれば、圧縮ファイル、リモートファイルを検索できる。 @@ -1024,11 +1087,13 @@ Note: 検索結果へのリンク一覧を開くには |:copen| (|:lgrep| なら れるだけである。[!] を付けるとカレントバッファに 対する変更は全て失われる。 - 'f' フラグ 'f' を指定するとファジー文字列マッチで一致 - する行が検索される。この場合 {pattern} は正規表現 - ではなくリテラル文字列として扱われる。文字列への - ファジーマッチについての詳細は |fuzzy-matching| - を参照。 + 'f' 'f' フラグが指定された場合、マッチする行を見つけ + るためにファジー文字列マッチが使用される。 + {pattern} に含まれる文字は、その順序通りに現れる + 必要がありるが、必ずしも隣接している必要はない。 + この場合、{pattern} は正規表現ではなく、リテラル + 文字列として扱われる。ファジー文字列マッチの詳細 + については、|fuzzy-matching| を参照。 |QuickFixCmdPre| と |QuickFixCmdPost| がトリガーされ る。 @@ -1214,6 +1279,16 @@ msg()関数を変更しているときに、上位から引数を得なければ うためのオプションが設定される。`:compiler` はローカルオプションを設定し、 `:compiler!` はグローバルオプションを設定する。 +通常の使用では、`:compiler {name}` でコンパイラを選択し、続いて |:make| を実行 +する。コンパイラプラグインは通常、Vim がコンパイラを実行してそのメッセージを読 +み取れるように、'makeprg' と 'errorformat' を設定する。以下の説明では、特定の +コンパイラプラグインのオプションについて解説する。 + +コンパイラプラグインによって設定された値は、後から |:set| や |:setlocal| で変 +更できる。`:compiler {name}` は現在のバッファに対してオプションを設定し、 +`:compiler! {name}` はグローバルなオプションを設定する。バッファローカルな値は +グローバルな値よりも優先される。 + *current_compiler* Vimの古いバージョンをサポートするために、それらのプラグインは常に "b:current_compiler" でなく "current_compiler" を使う。このコマンドが実際に行 @@ -1737,15 +1812,22 @@ Vim には Typst ファイル用のコンパイラプラグインが含まれて *errorformat* *E372* *E373* *E374* *E375* *E376* *E377* *E378* -'errorformat' オプションは認識されるエラーフォーマットのリストを指定する。その -中からエラーメッセージにマッチした最初のフォーマットが使われる。複数のフォーマッ -トを指定して、数種類のメッセージに対応したり、複数のコンパイラに対応したりする -ことができる。|efm-entries|を参照。 +'errorformat' オプションは、Vim がコンパイラの出力を読み取る際に使用するパター +ンを指定する。パターンを使用すると、各行からファイル名、行番号、列番号、および +メッセージを抽出できる。エラーメッセージにマッチする最初のフォーマットが使用さ +れる。コンパイラが出力するさまざまなメッセージに対応するフォーマットを複数追加 +したり、複数のコンパイラ用の設定を追加したりすることも可能であ +る。|efm-entries| を参照。 'errorformat' の各要素は、scanfに似たフォーマットを記述する文字列である。はじ めに、scanfがどのように働くか知る必要がある。Cコンパイラのドキュメントを読むこ と。以下はVimが理解する%の項目である。他は無効になる。 +クイックスタート: Vim には、一般的なコンパイラ向けのフォーマットがすでに多数組 +み込まれている。独自のフォーマットを作成する前に、|errorformats| で例を確認す +ること。該当する例がない場合は、以下の基本的な項目から始め、必要に応じて既存の +例を適宜調整すること。 + 'errorformat' 中の特別な文字はコンマとバックスラッシュである。それがどう扱われ るかは|efm-entries|を参照。Note "%%" はリテラル "%" にマッチする。よってこれは バックスラッシュでエスケープしない。 @@ -1779,6 +1861,7 @@ Vimは任意の長さの行を読み取るが、最初の4095バイトのみが w - 警告メッセージ i - 情報メッセージ n - ノートメッセージ + 大文字の E、W、I、N も認識され、同様の意味を持つ。 %n エラー番号 (数字を検索) %m エラーメッセージ (文字列を検索) %r その行の残り全部 %O/%P/%Q @@ -2090,6 +2173,12 @@ GNU-Makeではディレクトリに入ったり出たりすると常に絶対パ GNU-Makeに強制的に処理の前後にワーキングディレクトリを表示されるためにスイッ チ "-w" を使用するのは便利かもしれない。 +この点が問題となるのは、コンパイラの出力に複数のディレクトリにまたがる相対ファ +イル名が含まれている場合だけである。出力においてディレクトリの変更が明示的に示 +されないと、Vim は推測に頼らざるを得ず、誤ったファイルを選択してしまう可能性が +ある。絶対ディレクトリ名を出力し、ディレクトリに入った際と抜けた際の両方のメッ +セージを表示することで、この問題を回避できる。 + GNU-makeを使用しない場合、正しいディレクトリを管理する事はもっと複雑になる。 例えばAIX-makeはワーキングディレクトリに関してなんの情報も表示しない。 よってmakefileに細工が必要となる。LessTifのmakefileには "Making {target} in diff --git a/en/quickfix.txt b/en/quickfix.txt index 4b24d1298..b5d876598 100644 --- a/en/quickfix.txt +++ b/en/quickfix.txt @@ -1,4 +1,4 @@ -*quickfix.txt* For Vim version 9.2. Last change: 2026 May 28 +*quickfix.txt* For Vim version 9.2. Last change: 2026 Sep 14 VIM REFERENCE MANUAL by Bram Moolenaar @@ -41,24 +41,28 @@ From inside Vim an easy way to run a command and handle the output is with the |:make| command (see below). The 'errorformat' option should be set to match the error messages from your -compiler (see |errorformat| below). +compiler (see |errorformat| below). Vim uses it to extract information such +as the file name, line number and message from each line of compiler output. +Lines that do not match are kept as invalid entries and are skipped by +commands such as |:cnext|. Use |:clist|! to display them as well. *quickfix-stack* *quickfix-ID* *E1545* Each quickfix list has a unique identifier called the quickfix ID and this number will not change within a Vim session. The |getqflist()| function can be used to get the identifier assigned to a list. There is also a quickfix list -number which may change whenever more than 'chistory' lists are added to a -quickfix stack. +number, which is its position in the quickfix stack. This number may change +when lists are added or removed, or when more than 'chistory' lists are kept. +Use the ID when a script needs to refer to the same list reliably; use the +list number when referring to its current position in the stack. *location-list* *E776* -A location list is a window-local quickfix list. You get one after commands -like `:lvimgrep`, `:lgrep`, `:lhelpgrep`, `:lmake`, etc., which create a -location list instead of a quickfix list as the corresponding `:vimgrep`, -`:grep`, `:helpgrep`, `:make` do. +A location list is a quickfix list tied to one window. Each window can have a +separate location list, and commands such as `:lvimgrep`, `:lgrep`, +`:lhelpgrep` and `:lmake` use it instead of the global quickfix list. The +corresponding commands without the "l" prefix use the quickfix list. *location-list-file-window* -A location list is associated with a window and each window can have a -separate location list. A location list can be associated with only one -window. The location list is independent of the quickfix list. +The location list is independent of the quickfix list. A location list can +be associated with only one window. When a window with a location list is split, the new window gets a copy of the location list. When there are no longer any references to a location list, @@ -105,20 +109,22 @@ processing a quickfix or location list command, it will be aborted. *:cn* *:cne* *:cnext* *E553* :[count]cn[ext][!] Display the [count] next error in the list that - includes a file name. If there are no file names at - all, go to the [count] next error. See |:cc| for - [!] and 'switchbuf'. + includes a file name. Entries without a file name are + skipped, since Vim cannot use them to jump to a file. If + there are no file names at all, go to the [count] next + error. See |:cc| for [!] and 'switchbuf'. + +:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext* +:[count]cp[revious][!] Display the [count] previous error in the list that + includes a file name. Entries without a file name are + skipped, since Vim cannot use them to jump to a file. If + there are no file names at all, go to the [count] previous + error. See |:cc| for [!] and 'switchbuf'. *:lne* *:lnext* :[count]lne[xt][!] Same as ":cnext", except the location list for the current window is used instead of the quickfix list. -:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext* -:[count]cp[revious][!] Display the [count] previous error in the list that - includes a file name. If there are no file names at - all, go to the [count] previous error. See |:cc| for - [!] and 'switchbuf'. - :[count]lN[ext][!] *:lp* *:lprevious* *:lprev* *:lN* *:lNext* :[count]lp[revious][!] Same as ":cNext" and ":cprevious", except the location @@ -240,9 +246,10 @@ processing a quickfix or location list command, it will be aborted. execute the command, etc. {N} can also be zero, in which case Vim exits normally. - WARNING: All changes in files are lost! Also when the - [!] is not used. It works like ":qall!" |:qall|, - except that Vim returns a non-zero exit code. + WARNING: This abandons changes in all files, like + |:qall|!. + The [!] does not change this. Vim returns a non-zero + exit code, unless {N} is zero. *:cf* *:cfi* *:cfile* :cf[ile][!] [errorfile] Read the error file and jump to the first error. @@ -286,14 +293,21 @@ processing a quickfix or location list command, it will be aborted. :laddf[ile] [errorfile] Same as ":caddfile", except the location list for the current window is used instead of the quickfix list. +The following commands read error messages from a buffer: +`:cbuffer` creates a list and jumps to its first error, `:cgetbuffer` +creates a list without jumping, and `:caddbuffer` adds entries to the +current list without changing the cursor position. The corresponding +commands with an "l" prefix use the location list. + *:cb* *:cbuffer* *E681* :[range]cb[uffer][!] [bufnr] Read the error list from the current buffer. When [bufnr] is given it must be the number of a loaded buffer. That buffer will then be used instead of the current buffer. - A range can be specified for the lines to be used. - Otherwise all lines in the buffer are used. + A range can be specified for the lines to be used, for + example `:10,20cbuffer`. Otherwise all lines in the + buffer are used. See |:cc| for [!]. *:lb* *:lbuffer* @@ -325,6 +339,12 @@ processing a quickfix or location list command, it will be aborted. the current window is used instead of the quickfix list. +The following commands create or update a quickfix list from an expression: +`:cexpr` creates a list and jumps to its first error, `:cgetexpr` creates a +list without jumping, and `:caddexpr` adds entries to the current list without +changing the cursor position. The corresponding commands with an "l" prefix +use the location list. + *:cex* *:cexpr* *E777* :cex[pr][!] {expr} Create a quickfix list using the result of {expr} and jump to the first error. @@ -376,6 +396,8 @@ processing a quickfix or location list command, it will be aborted. quickfix entries matching a supplied pattern. The pattern is matched against the filename, module name, pattern and text of the entry. + For example, `:filter /\.c:/clist` lists only entries + whose displayed text contains `.c:`. See |:filter|. :cl[ist] +{count} List the current and next {count} valid errors. This is similar to ":clist from from+count", where "from" @@ -424,7 +446,7 @@ use this code: > call setqflist(qflist) endfunction - au QuickfixCmdPost make call QfMakeConv() + au QuickFixCmdPost make call QfMakeConv() Another option is using 'makeencoding'. *quickfix-title* @@ -489,6 +511,19 @@ entries parsed from lines. The following shows how to use a custom echo getqflist({'efm' : '%f#%l#%m', 'lines' : ['F1#10#Line']}) < +To execute a command for entries or files in a list, use: + + Quickfix list Location list + Each entry :cdo :ldo + Each file :cfdo :lfdo + +Use `:cdo` when a command should run for every valid entry, for example +`:cdo s/old/new/g` to change each matching line. Use `:cfdo` when it should +run once for each file, for example `:cfdo update` to write each affected +file once. Add the "l" prefix to use the location list instead. + +The commands below describe these differences in more detail. + EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST: *:cdo* :cdo[!] {cmd} Execute {cmd} in each valid entry in the quickfix @@ -667,8 +702,9 @@ instead. If the buffer in the used window has changed, and the error is in another file, jumping to the error will fail. You will first have to make sure the window contains a buffer which can be abandoned. -When you select a file from the quickfix window, the following steps are used -to find a window to edit the file: +When you select a file from the quickfix window, Vim first reuses a window +that already displays the file. Otherwise it uses a suitable window in the +current tab page, or opens a new one. The detailed selection rules are: 1. If a window displaying the selected file is present in the current tabpage (starting with the window before the quickfix window), then that window is @@ -687,6 +723,15 @@ to find a window to edit the file: 6. If the above step fails, then a new horizontally split window above the quickfix window is used. + *quickfix-winfixbuf* +When 'winfixbuf' is set for the window that would be used to display the +error, jumping to an error in another buffer is not possible in that window. +For a quickfix list Vim then looks for another suitable window, using the +previously accessed window if it does not have 'winfixbuf' set, and otherwise +splits a new window. For a location list this fails with |E1513|, because a +location list is tied to its window and cannot move to or split off another +one. Using [!] skips these checks. + *CTRL-W_* *CTRL-W_* You can use CTRL-W to open a new window and jump to the error there. @@ -722,8 +767,10 @@ is similar to the quickfix window, except that you can have more than one location list window open at a time. When you use a location list command in this window, the displayed location list is used. -When you select a file from the location list window, the following steps are -used to find a window to edit the file: +When you select a file from the location list window, Vim first uses the +window associated with that location list, when possible. Otherwise it +reuses a suitable window or opens a new one. The detailed selection rules +are: 1. If a non-quickfix window associated with the location list is present in the current tabpage, then that window is used. @@ -955,6 +1002,13 @@ To get the number of the current list in the stack: > Same as ":make", except the location list for the current window is used instead of the quickfix list. +In short, `:make` runs 'makeprg', reads its output using 'errorformat', +optionally jumps to the first recognized error, and then removes the temporary +error file used by the normal `:make` workflow. If 'shellpipe' is empty, or +if the program manages its own output file, this cleanup does not apply to +that program's file. Use |:cnext| and related commands to move through the +resulting list. + The ":make" command executes the command given with the 'makeprg' option. This is done by passing the command to the shell given with the 'shell' option. This works almost like typing @@ -1005,7 +1059,7 @@ read the error messages: > call setqflist(qflist) endfunction - au QuickfixCmdPost make call QfMakeConv() + au QuickFixCmdPost make call QfMakeConv() (Example by Faque Cheng) Another option is using 'makeencoding'. @@ -1018,8 +1072,9 @@ advantage of the internal grep is that it works on all systems and uses the powerful Vim search patterns. An external grep program can be used when the Vim grep does not do what you want. -The internal method will be slower, because files are read into memory. The -advantages are: +The internal method will be slower, because files are read into memory. For +large projects, consider using |:grep| with an external search program. The +advantages of the internal method are: - Line separators and encoding are automatically recognized, as if a file is being edited. - Uses Vim search patterns. Multi-line patterns can be used. @@ -1071,9 +1126,11 @@ commands can be combined to create a NewGrep command: > buffer are abandoned. 'f' When the 'f' flag is specified, fuzzy string - matching is used to find matching lines. In this - case, {pattern} is treated as a literal string - instead of a regular expression. See + matching is used to find matching lines. The + characters in {pattern} must appear in order, but + need not be next to each other. In this case, + {pattern} is treated as a literal string instead of + a regular expression. See |fuzzy-matching| for more information about fuzzy matching strings. @@ -1266,6 +1323,17 @@ need to write down a "todo" list. The Vim plugins in the "compiler" directory will set options to use the selected compiler. For `:compiler` local options are set, for `:compiler!` global options. + +In normal use, select a compiler with `:compiler {name}` and then run +|:make|. The compiler plugin usually sets 'makeprg' and 'errorformat' so +Vim can run the compiler and read its messages. The descriptions below +document options for particular compiler plugins. + +The values set by a compiler plugin can be changed afterwards with |:set| or +|:setlocal|. `:compiler {name}` sets options for the current buffer, while +`:compiler! {name}` sets global options; a buffer-local value takes precedence +over a global value. + *current_compiler* To support older Vim versions, the plugins always use "current_compiler" and not "b:current_compiler". What the command actually does is the following: @@ -1788,16 +1856,21 @@ This can be changed by setting the |g:typst_cmd| variable: > *errorformat* *E372* *E373* *E374* *E375* *E376* *E377* *E378* -The 'errorformat' option specifies a list of formats that are recognized. The -first format that matches with an error message is used. You can add several -formats for different messages your compiler produces, or even entries for -multiple compilers. See |efm-entries|. +The 'errorformat' option specifies patterns that Vim uses to read compiler +output. A pattern can extract the file name, line number, column and message +from each line. The first format that matches with an error message is used. +You can add several formats for different messages your compiler produces, or +even entries for multiple compilers. See |efm-entries|. Each entry in 'errorformat' is a scanf-like string that describes the format. First, you need to know how scanf works. Look in the documentation of your C compiler. Below you find the % items that Vim understands. Others are invalid. +Quick start: Vim already includes formats for many common compilers. Check +|errorformats| for an example before writing your own. If no example matches, +start with the basic items below and adapt one of the examples as needed. + Special characters in 'errorformat' are comma and backslash. See |efm-entries| for how to deal with them. Note that a literal "%" is matched by "%%", thus it is not escaped with a backslash. @@ -1833,6 +1906,8 @@ Basic items w - warning message i - info message n - note message + The uppercase letters E, W, I and N are also + recognized and have the same meaning. %n error number (finds a number) %m error message (finds a string) %r matches the "rest" of a single-line file message %O/P/Q @@ -2156,6 +2231,12 @@ to directory before reading the makefile). It may be useful to use the switch "-w" to force GNU-make to print out the working directory before and after processing. +This matters only when compiler output contains relative file names from +multiple directories. If the output does not clearly report directory +changes, Vim has to guess and can select the wrong file. Printing absolute +directory names and both entering and leaving directory messages avoids this +problem. + Maintaining the correct directory is more complicated if you don't use GNU-make. AIX-make for example doesn't print any information about its working directory. Then you need to enhance the makefile. In the makefile of