Skip to content

Commit f8f8d29

Browse files
committed
Update remote.{txt,jax}
1 parent e8fee57 commit f8f8d29

File tree

2 files changed

+149
-8
lines changed

2 files changed

+149
-8
lines changed

doc/remote.jax

Lines changed: 74 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 18
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -62,7 +62,9 @@ Vimクライアントサーバー通信 *client-server*
6262
--servername {name} サーバー名{name}になる。--remote コマンドのど
6363
れか1つと併用すると、デフォルトのサーバーでは
6464
なく{name}で指定されるサーバーに接続する(下を
65-
参照)。使用される名前は大文字になる。
65+
参照)。使用される名前は大文字になる。ソケット
66+
サーバーを使用する場合は、パスを指定できる。詳
67+
細については |socketserver-name| を参照。
6668
*--remote-send*
6769
--remote-send {keys} サーバーに{keys}を送信して終了する。{keys}
6870
マップは適用されない。特殊キー名が使用できる。
@@ -72,6 +74,12 @@ Vimクライアントサーバー通信 *client-server*
7274
出力に印刷する。
7375
*--serverlist*
7476
--serverlist サーバー名のリストを表示する。
77+
*--clientserver*
78+
--clientserver {method} 指定されたメソッド {method} をクライアントサー
79+
バー機能のバックエンドとして使用する。"socket"
80+
または "x11" のいずれかを指定できる。
81+
{Vim が |+X11||+socketserver| の両方の機能
82+
付きでコンパイルされたときのみ有効}
7583

7684

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

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

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

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

en/remote.txt

Lines changed: 75 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 21
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -61,7 +61,10 @@ The following command line arguments are available:
6161
--servername {name} Become the server {name}. When used together
6262
with one of the --remote commands: connect to
6363
server {name} instead of the default (see
64-
below). The name used will be uppercase.
64+
below). The name used will be uppercase. If
65+
using the socketserver, you can specify a
66+
path, see |socketserver-name| for more
67+
details.
6568
*--remote-send*
6669
--remote-send {keys} Send {keys} to server and exit. The {keys}
6770
are not mapped. Special key names are
@@ -72,6 +75,12 @@ The following command line arguments are available:
7275
on stdout.
7376
*--serverlist*
7477
--serverlist Output a list of server names.
78+
*--clientserver*
79+
--clientserver {method} Use the specified method {method} as the
80+
backend for clientserver functionality. Can
81+
either be "socket" or "x11".
82+
{only available when compiled with both |+X11|
83+
and |+socketserver| features}
7584

7685

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

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

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

0 commit comments

Comments
 (0)