Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dict.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ Vim9 script:
- オペレーター
- 演算コマンド

フィルタ:
- フィルター

フォントセット:
- フォント・セット

Expand Down
174 changes: 137 additions & 37 deletions doc/terminal.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*terminal.txt* For Vim バージョン 9.1. Last change: 2025 Sep 15
*terminal.txt* For Vim バージョン 9.1. Last change: 2025 Oct 14


VIMリファレンスマニュアル by Bram Moolenaar
Expand All @@ -13,39 +13,40 @@
結果が "1" の場合、対応している。


1. 基本的な使い方 |terminal-use|
キー入力 |terminal-typing|
サイズと色 |terminal-size-color|
文法 |:terminal|
サイズ変更 |terminal-resizing|
端末モード |Terminal-mode|
カーソルスタイル |terminal-cursor-style|
セッション |terminal-session|
特別なキー |terminal-special-keys|
Unix |terminal-unix|
MS-Windows |terminal-ms-windows|
1. 基本的な使い方 |terminal-use|
キー入力 |terminal-typing|
サイズと色 |terminal-size-color|
文法 |:terminal|
サイズ変更 |terminal-resizing|
端末モード |Terminal-mode|
カーソルスタイル |terminal-cursor-style|
セッション |terminal-session|
特別なキー |terminal-special-keys|
Unix |terminal-unix|
MS-Windows |terminal-ms-windows|
2. 端末関数 |terminal-function-details|
3. 端末通信 |terminal-communication|
Vim からジョブへ: term_sendkeys() |terminal-to-job|
ジョブから Vim へ: JSON API |terminal-api|
クライアントサーバー機能を使う |terminal-client-server|
4. リモートテスト |terminal-testing|
5. 画面ダンプの差分 |terminal-diff|
Vimの画面ダンプテストを書く |terminal-dumptest|
画面ダンプを作成する |terminal-screendump|
画面ダンプを比較する |terminal-diffscreendump|
6. デバッグ |terminal-debug|
はじめに |termdebug-starting|
セッション例 |termdebug-example|
コードをステップ実行する |termdebug-stepping|
変数を検査する |termdebug-variables|
スタックフレームの移動 |termdebug-frames|
その他のコマンド |termdebug-commands|
イベント |termdebug-events|
プロンプトモード |termdebug-prompt|
マッピング |termdebug-mappings|
通信 |termdebug-communication|
カスタマイズ |termdebug-customizing|
Vim からジョブへ: term_sendkeys() |terminal-to-job|
ジョブから Vim へ: JSON API |terminal-api|
クライアントサーバー機能を使う |terminal-client-server|
4. リモートテスト |terminal-testing|
5. 画面ダンプの差分 |terminal-diff|
Vimの画面ダンプテストを書く |terminal-dumptest|
画面ダンプを作成する |terminal-screendump|
画面ダンプを比較する |terminal-diffscreendump|
6. デバッグ |terminal-debug|
はじめに |termdebug-starting|
セッション例 |termdebug-example|
コードをステップ実行する |termdebug-stepping|
変数を検査する |termdebug-variables|
スタックフレームの移動 |termdebug-frames|
その他のコマンド |termdebug-commands|
イベント |termdebug-events|
プロンプトモード |termdebug-prompt|
マッピング |termdebug-mappings|
通信 |termdebug-communication|
リモートデバッグ |termdebug-remote|
カスタマイズ |termdebug-customizing|

{Vimが |+terminal| 機能付きでコンパイルされたときのみ有効}
端末機能を使うには |+job| と |+channel| 機能が必要である。
Expand Down Expand Up @@ -1609,25 +1610,124 @@ gdb は奇妙な動作をしているが、プラグインはその問題を回
`:Continue` コマンドに "continue" が使用されていることが分かる。


リモートデバッグ ~
*termdebug-remote*
リモートデバッグにおける主な問題の 1 つは、デバッグ対象のソースファイルへのアク
セスである。プラグインは、システムと Vim のネットワーク機能を使用してこの問題を
回避できる。
*termdebug-remote-example*
|termdebug-example| は、`gdb` デバッガーを実行して `ssh` 経由でアクセス可能な
リモート Linux マシン上の Vim をデバッグすることで再現できる。

- ローカルの例の説明に従って Vim をビルドする。

リモートマシンで "socat" が使用できない場合、'terminal' モードは正常に動作しな
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原文からですが、ここの socat はコマンドなのに(サービス、機能ともいえますが)、ダブルクォートなんですね

い。|termdebug_use_prompt| にフォールバックする: >
:let g:termdebug_config = {}
:let g:termdebug_config['use_prompt'] = v:true

- リモート `gdb` インスタンスを実行するためのコマンドラインを指定する: >
:let g:termdebug_config['command'] = ['ssh', 'hostname', 'gdb']
< この例では `ssh` の説明は範囲外だが、`$HOME/.ssh/config` ファイルにユーザー、
キー、その他のオプションを指定することによって、コマンドラインを大幅に簡素化
できることに注目して欲しい。

- リモートパスを |netrw| パスに変換するためのヒントを提供する: >
:let g:termdebug_config['substitute_path'] = { '/': 'scp://hostname//' }

- termdebug プラグインをロードし、Vim のデバッグを開始する: >
:packadd termdebug
:Termdebug vim

これで、ローカルの例と同じ 3 つのウィンドウが表示され、同じ手順を実行できる。
唯一の違いは、ソースウィンドウにローカルバッファではなく netrw バッファが表示
されることである。

*termdebug-substitute-path*
`g:termdebug_config['substitute_path']` エントリを使用して、gdb の
`substitute-path` コマンドと同じ戦略でリモートファイルをローカルファイルにマッ
ピングする。例:
- ssh 経由でリモートファイルにアクセスするには、|netrw| を使用する: >
let g:termdebug_config['command'] = ['ssh', 'hostname', 'gdb']
let g:termdebug_config['substitute_path'] = { '/': 'scp://hostname//' }
< Note: キーはリモートマシンのルートパスを指定し、値はローカルマシンのルートパ
スを指定する。
- Windows の `UNC` パスを使用して `WSL2` ソースにアクセスする: >
let g:termdebug_config['command'] = ['wsl', 'gdb']
let g:termdebug_config['substitute_path'] = {
\ '/': '\\wsl.localhost\Ubuntu-22.04\',
\ '/mnt/c/': 'C:/' }
< Note: 複数のマッピングが必要である。各ドライブユニットに 1 つ、Linux ファイ
ルシステムに 1 つ (`wslpath` 経由で照会)。

このモードでは、すべての `ssh` または `wsl` コマンドが検出され、同様のコマンド
を使用してリモート `tty` 端末セッションで `socat` を起動し、それを `gdb` に接
続する。
`socat` が使用できない場合は、フォールバックとして通常のリモート端末が使用され
る。
次のセッションでは、このデフォルトの動作をオーバーライドする方法を説明する。

*termdebug-remote-window*
別のリモート端末クライアントを使用するには、`:Termdebug` を呼び出す前に、
`g:termdebug_config` 変数の "remote_window" エントリを設定する。例:
- "prompt" モードを使用して Docker コンテナ内でデバッグする: >
let g:termdebug_config['use_prompt'] = v:true
let g:termdebug_config['command'] = ['docker', 'run', '-i',
\ '--rm', '--name', 'container-name', 'image-name', 'gdb']
let g:termdebug_config['remote_window'] =
\ ['docker', 'exec', '-ti', 'container-name'
\ ,'socat', '-dd', '-', 'PTY,raw,echo=0']

- "terminal buffer" を使用して Docker コンテナ内でデバッグする。
コンテナは既に実行されているはずである。これは、前述の `terminal mode` の場
合とは異なり、"program" および "communication" pty が gdb pty の前に作成され
るためである: >
$ docker run -ti --rm --name container-name immage-name

< 次に、デバッガーを起動する: >
let g:termdebug_config['use_prompt'] = v:false " default
let g:termdebug_config['command'] =
\ ['docker', 'exec', '-ti', 'container-name', 'gdb']
let g:termdebug_config['remote_window'] =
\ ['docker', 'exec', '-ti', 'container-name'
\ ,'socat', '-dd', '-', 'PTY,raw,echo=0']

Note: プロンプトバッファが `tty` 接続を処理できないため、"command" は
|termdebug-prompt| モードで `-t` を使用できない。
"remote_window" コマンドでは `-t` を使用する必要がある。そうしなければ、gdb が
接続するための `pty slave device` が不足する。
Note: "socat" は、リモートマシンの "terminal" モードで使用可能である必要がある。
Note: docker コンテナソースは、`volumes` とマッピングを組み合わせてアクセスで
きる (|termdebug-substitute-path| を参照)。

GDBコマンド ~
*g:termdebugger*
gdb コマンド以外のデバッガを使うには、`:Termdebug` を実行する前に
g:termdebug_config の "debugger" エントリか "g:termdebugger" 変数を変更する: >
let g:termdebug_config['command'] = "mygdb"

g:termdebug_config がない場合は、以下を使用できる: >
let g:termdebugger = "mygdb"

ただし、後者の形式は将来のリリースでは非推奨になりる。

コマンドに引数が必要な場合はリストを使用する: >
let g:termdebug_config['command'] = ['rr', 'replay', '--']

g:termdebug_config がない場合は、以下を使用できる: >
let g:termdebugger = ['rr', 'replay', '--']

gdb がデバッガで適切に動作するように、いくつかの引数が追加される。それらを変更
したい場合は、引数リストをフィルタリングする関数を追加する: >
let g:termdebug_config['command_filter'] = MyDebugFilter

"command_filter" シナリオは、ssh 経由のリモートデバッグにおけるエスケープの問
題を解決する。便宜上、引数内の空白をエスケープするためのデフォルトフィルタが用
意されている。このフィルタは ssh 用に自動的に設定されるが、以下のような他のユー
スケースにも使用できる: >
let g:termdebug_config['command_filter'] =
/ function('g:Termdebug_escape_whitespace')

引数を追加したくないが、"pty" を設定する必要がある場合は、関数を使用して必要な
引数を追加する: >
let g:termdebug_config['command_add_args'] = MyAddArguments
Expand Down Expand Up @@ -1682,15 +1782,15 @@ g:termdebug_config がない場合は、以下を使用できる: >
デフォルトの目印の変更 ~
*termdebug_signs*
Termdebug は、signcolumn のブレークポイント ID の 16 進数を使用してブレークポ
イントを表す。"0xFF" より大きい場合は、実際には記号用の画面セルが 2 つしかない
ため、"F+" と表示される。
代わりに 10 進数のブレークポイントの目印を使用することもできる。その場合、99
より大きい ID は "9+" と表示される。
イントを表す。"0xFF" より大きい場合、目印に使用できる画面セルは 2 つしかないた
め、"F+" と表示される。代わりに 10 進数のブレークポイントの目印を使用すること
もできる。その場合、99 より大きい ID は "9+" と表示される。

ブレークポイントの目印をカスタマイズして、signcolumn に `>>` を表示するには: >
let g:termdebug_config['sign'] = '>>'
最初のいくつかのブレークポイントに個別の記号を指定することもできる: >
let g:termdebug_config['signs'] = ['>1', '>2', '>3', '>4', '>5', '>6', '>7', '>8', '>9']
let g:termdebug_config['signs'] = ['>1', '>2', '>3', '>4', '>5',
\ '>6', '>7', '>8', '>9']
let g:termdebug_config['sign'] = '>>'
10 進数 (基数 10) のブレークポイントの目印を使用するには: >
let g:termdebug_config['sign_decimal'] = 1
Expand Down
Loading