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
7786Examples ~
@@ -105,7 +114,8 @@ specified name is not available, a postfix is applied until a free name is
105114encountered, i.e. "gvim1" for the second invocation of gvim on a particular
106115X-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
110120When Vim is invoked with --remote, --remote-wait or --remote-send it will try
111121to 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
119129when sending command to it.
120130
121131The --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}*
124135The {server} argument is used by several functions. When this is an empty
125136string 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