Skip to content

Commit 5a197b3

Browse files
authored
Merge pull request #2266 from h-east/update-remote
Update remote.{txt,jax}
2 parents 158599e + 9e8080c commit 5a197b3

File tree

2 files changed

+151
-8
lines changed

2 files changed

+151
-8
lines changed

doc/remote.jax

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*remote.txt* For Vim バージョン 9.1. Last change: 2022 Feb 17
1+
*remote.txt* For Vim バージョン 9.1. Last change: 2025 Aug 22
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -9,6 +9,7 @@ Vimクライアントサーバー通信 *client-server*
99
1. 共通機能 |clientserver|
1010
2. X11特有の項目 |x11-clientserver|
1111
3. Win32特有の項目 |w32-clientserver|
12+
4. ソケットサーバー固有の項目 |socketserver-clientserver|
1213

1314
==============================================================================
1415
1. 共通機能 *clientserver*
@@ -62,7 +63,9 @@ Vimクライアントサーバー通信 *client-server*
6263
--servername {name} サーバー名{name}になる。--remote コマンドのど
6364
れか1つと併用すると、デフォルトのサーバーでは
6465
なく{name}で指定されるサーバーに接続する(下を
65-
参照)。使用される名前は大文字になる。
66+
参照)。使用される名前は大文字になる。ソケット
67+
サーバーを使用する場合は、パスを指定できる。詳
68+
細については |socketserver-name| を参照。
6669
*--remote-send*
6770
--remote-send {keys} サーバーに{keys}を送信して終了する。{keys}
6871
マップは適用されない。特殊キー名が使用できる。
@@ -72,6 +75,12 @@ Vimクライアントサーバー通信 *client-server*
7275
出力に印刷する。
7376
*--serverlist*
7477
--serverlist サーバー名のリストを表示する。
78+
*--clientserver*
79+
--clientserver {method} 指定されたメソッド {method} をクライアントサー
80+
バー機能のバックエンドとして使用する。"socket"
81+
または "x11" のいずれかを指定できる。
82+
{Vim が |+X11||+socketserver| の両方の機能
83+
付きでコンパイルされたときのみ有効}
7584

7685

7786
使用例 ~
@@ -103,7 +112,8 @@ Vimクライアントサーバー通信 *client-server*
103112
は、利用できる名前になるように後置名が付加される。例えば、1つのX-Serverで2つ目
104113
のgvimを起動したときには "gvim1" というようになる。その時のサーバー名へは組み
105114
込み変数|v:servername|によりアクセスできる。サーバー名の大文字小文字は区別され
106-
ないので、"gvim" と "GVIM" は同じとみなされる。
115+
ないので、"gvim" と "GVIM" は同じとみなされる。Note ソケットサーバーが使用され
116+
ている場合、いくつかの違いがあることに注意。|socketserver-differences| を参照。
107117

108118
Vimが引数 --remote や --remote-wait または --remote-send で起動された時には、
109119
上記のようにその名前で起動されたサーバーを探そうと試みる。正確に一致するサー
@@ -117,7 +127,8 @@ Vimが引数 --remote や --remote-wait または --remote-send で起動され
117127
かを知る必要は無い。
118128

119129
引数 --serverlist はVimに登録(実行)されている全てのコマンドサーバーを、標準出
120-
力(stdout)に印刷して終了する。
130+
力(stdout)に印刷して終了する。ソケットサーバーが使用されている場合は注意点があ
131+
る。|socketserver-differences| を参照。
121132

122133
*{server}*
123134
引数 {server} はいくつかの関数で使われる。これが空文字列の場合、Unix ではデフォ
@@ -200,4 +211,64 @@ gvimを使っている時には、--remote-wait は以下のようにしない
200211
201212
start /w gvim --remote-wait file.txt
202213
<
214+
==============================================================================
215+
4. ソケットサーバー固有の項目 *socketserver-clientserver*
216+
*E1563* *E1564* *E1565* *E1566* *E1567*
217+
218+
クライアントとサーバー間の通信は Unix ドメインソケットを使用して行われる。これ
219+
らのソケットは、以下の利用可能な順序で以下のディレクトリに配置される。
220+
1. 環境に $XDG_RUNTIME_DIR が設定されている場合は "$XDG_RUTIME_DIR/vim"。
221+
2. "$TMPDIR/vim-[uid]"。ここで "[uid]" はユーザーの uid である。このディレ
222+
クトリのアクセス権限は 700 に設定され、ユーザーのみが読み書きできる。
223+
$TMPDIR が設定されていない場合は、"/tmp" が使用される。
224+
225+
*socketserver-name*
226+
サーバー id/名前を指定する際は、汎用名、絶対パス、または相対パスで指定できる。
227+
サーバー id が "/" (絶対パス) または "./" または "../" (相対パス) で始まる場
228+
合、ソケットへのパスとして扱われる。それ以外の場合、サーバー id は上記の共通
229+
ディレクトリに配置されるソケットのファイル名になる。Note サーバー id/名前をパ
230+
スとして指定する場合、スラッシュ "/" のみを含めることができる。"abc/dir" のよ
231+
うな名前は無効である。
232+
233+
ソケットサーバー機能は、GTK GUI 版とターミナル版の両方の Vim で使用できる。Vim
234+
|+autoservername| 機能付きでコンパイルされていない場合、GUI 版であっても
235+
X11 と同様にソケットサーバーを明示的に起動する必要がある。
236+
237+
Vim がクラッシュしたり、正常に終了しなかったりした場合、ソケットサーバーはソ
238+
ケットファイルを削除せずそのまま残す。これは通常問題にはならない。ソケット名が
239+
既に使用されている場合、Vim はそのソケットがデッド (どのプロセスにも接続されて
240+
いない) かどうかを確認し、新しい名前を探す代わりに既存のソケットを置き換えるこ
241+
とができるためである。
242+
243+
別のアプリケーションから Vim ソケットサーバーにコマンドを送信するには、ソース
244+
ファイル src/os_unix.c を読むこと。そこには、使用されるプロトコルの詳細な説明
245+
があります。
246+
247+
*socketserver-differences*
248+
機能の大部分は X11 と同じたが、X11 ではクライアントがサーバーとして動作してい
249+
なくてもサーバーと通信できるのに対し、ソケットサーバーではクライアントであって
250+
もサーバーが動作している必要がある。ただし、|serverlist()| または
251+
|--serverlist| 引数は例外で、サーバーが動作している必要はない。
252+
253+
さらに、サーバー id またはクライアント id は、X11 や MS-Windows のような数値
254+
(16進数で表示) ではなく、ソケットへの絶対パスになる。これは |v:servername|
255+
数で確認できる。
256+
257+
|--serverlist| 引数は X11 と同様に動作するが、確認対象は上記で挙げた共通ディレ
258+
クトリに限られる。したがって、ソケットにカスタムのパスを使用している場合は検出
259+
されない。例えば、|--serverlist| を実行している Vim プロセスの
260+
$XDG_RUNTIME_DIR 以外、あるいは <$TMPDIR または /tmp> /vim 以外の場所にあるパ
261+
スは検出対象にならない。
262+
263+
|+socketserver||+X11| の両方をコンパイルしている場合、使用可能なサーバーの
264+
一覧を表示するには、|--clientserver| を "socket" に設定し、|--serverlist| と組
265+
み合わせて追加する必要がある。1 つのコマンドで両方の種類のバックエンドの一覧を
266+
表示することはできない。
267+
268+
*socketserver-x11*
269+
Vim が |+X11||+socketserver| の両方でコンパイルされている場合、どちらのバッ
270+
クエンドを使用するかは起動時に |--clientserver| 引数によって決定される。指定さ
271+
れていない場合はデフォルトで X11 が使用される。ソケットサーバーを使用する Vim
272+
インスタンスは、X11 を使用する Vim インスタンスと通信できない。
273+
203274
vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

en/remote.txt

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*remote.txt* For Vim version 9.1. Last change: 2022 Feb 17
1+
*remote.txt* For Vim version 9.1. Last change: 2025 Aug 22
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -9,6 +9,7 @@ Vim client-server communication *client-server*
99
1. Common functionality |clientserver|
1010
2. X11 specific items |x11-clientserver|
1111
3. MS-Windows specific items |w32-clientserver|
12+
4. Socket server specific items |socketserver-clientserver|
1213

1314
==============================================================================
1415
1. Common functionality *clientserver*
@@ -61,7 +62,10 @@ The following command line arguments are available:
6162
--servername {name} Become the server {name}. When used together
6263
with one of the --remote commands: connect to
6364
server {name} instead of the default (see
64-
below). The name used will be uppercase.
65+
below). The name used will be uppercase. If
66+
using the socketserver, you can specify a
67+
path, see |socketserver-name| for more
68+
details.
6569
*--remote-send*
6670
--remote-send {keys} Send {keys} to server and exit. The {keys}
6771
are not mapped. Special key names are
@@ -72,6 +76,12 @@ The following command line arguments are available:
7276
on stdout.
7377
*--serverlist*
7478
--serverlist Output a list of server names.
79+
*--clientserver*
80+
--clientserver {method} Use the specified method {method} as the
81+
backend for clientserver functionality. Can
82+
either be "socket" or "x11".
83+
{only available when compiled with both |+X11|
84+
and |+socketserver| features}
7585

7686

7787
Examples ~
@@ -105,7 +115,8 @@ specified name is not available, a postfix is applied until a free name is
105115
encountered, i.e. "gvim1" for the second invocation of gvim on a particular
106116
X-server. The resulting name is available in the servername builtin variable
107117
|v:servername|. The case of the server name is ignored, thus "gvim" and
108-
"GVIM" are considered equal.
118+
"GVIM" are considered equal. Note if a socket server is being used, there are
119+
some differences, see |socketserver-differences|.
109120

110121
When Vim is invoked with --remote, --remote-wait or --remote-send it will try
111122
to locate the server name determined by the invocation name and --servername
@@ -119,7 +130,8 @@ itself. This way it is not necessary to know whether gvim is already started
119130
when sending command to it.
120131

121132
The --serverlist argument will cause Vim to print a list of registered command
122-
servers on the standard output (stdout) and exit.
133+
servers on the standard output (stdout) and exit. If a socket server is being
134+
used, there are caveats, see |socketserver-differences|.
123135
*{server}*
124136
The {server} argument is used by several functions. When this is an empty
125137
string then on Unix the default server name is used, which is "GVIM". On
@@ -206,4 +218,64 @@ When using gvim, the --remote-wait only works properly this way: >
206218
207219
start /w gvim --remote-wait file.txt
208220
<
221+
==============================================================================
222+
4. Socket server specific items *socketserver-clientserver*
223+
*E1563* *E1564* *E1565* *E1566* *E1567*
224+
225+
The communication between client and server is done using Unix domain sockets.
226+
These sockets are either placed in these directories in the following order of
227+
availability:
228+
1. "$XDG_RUTIME_DIR/vim" if $XDG_RUNTIME_DIR is set in the environment.
229+
2. "$TMPDIR/vim-[uid]", where "[uid]" is the uid of the user. This
230+
directory will have the access permissions set to 700 so only the user
231+
can read or write from/to it. If $TMPDIR is not set, "/tmp" is used.
232+
233+
*socketserver-name*
234+
When specifying the server id/name, it can be taken as a generic name or an
235+
absolute or relative path. If the server id starts with either a "/"
236+
(absolute) or "./" | "../" (relative), then it is taken as path to the socket.
237+
Otherwise the server id will be the filename of the socket which will be
238+
placed in the above common directories. Note that a server id/name can only
239+
contain slashes "/" if it is taken as a path, so names such as "abc/dir" will
240+
be invalid.
241+
242+
Socket server functionality is available in both GTK GUI and terminal versions
243+
of Vim. Unless Vim is compiled with |+autoservername| feature, the socket
244+
server will have to started explicitly, just like X11, even in the GUI.
245+
246+
If Vim crashes or does not exit cleanly, the socket server will not remove the
247+
socket file and it will be left around. This is generally not a problem,
248+
because if a socket name is taken, Vim checks if the socket in its place is
249+
dead (not attached to any process), and can replace it instead of finding a
250+
new name.
251+
252+
To send commands to a Vim socket server from another application, read the
253+
source file src/os_unix.c, there is detailed description of the protocol used.
254+
255+
*socketserver-differences*
256+
Most of the functionality is the same as X11, however unlike X11, where the
257+
client does not need to be a server in order to communicate with another
258+
server, the socket server requires the server to be running even as a client.
259+
The exception is |serverlist()| or the |--serverlist| argument, which does not
260+
require the server to be running.
261+
262+
Additionally, the server id or client id will not be a number like X11 or
263+
MS-Windows (shown in hex representation), instead it is the absolute path to
264+
the socket. This can be seen via the |v:servername| variable.
265+
266+
The |--serverlist| argument will act just like X11, however it only checks the
267+
given common directories above. If a custom path is used for a socket, it
268+
will not be detected, such as a path either not in $XDG_RUNTIME_DIR or
269+
<$TMPDIR or /tmp>/vim of the |--serverlist| Vim process.
270+
271+
If you have both |+socketserver| and |+X11| compiled, you will need to add
272+
|--clientserver| set to "socket" in combination with |--serverlist| to list
273+
the available servers. You cannot list both types of backends in one command.
274+
275+
*socketserver-x11*
276+
If Vim is compiled with both |+X11| and |+socketserver|, then deciding which
277+
backend to use is done at startup time, via the |--clientserver| argument. By
278+
default if it is not specified, then X11 will be used. A Vim instance using a
279+
socket server cannot communicate with one using X11.
280+
209281
vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)