remote.txt For Vim version 9.1. Last change: 2025 Nov 09 VIM REFERENCE MANUAL by Bram Moolenaar Vim client-server communication client-server 1. Common functionality clientserver 2. X11 specific items x11-clientserver 3. MS-Windows specific items w32-clientserver 4. Socket server specific items socketserver-clientserver ============================================================================== 1. Common functionality clientserver When compiled with the +clientserver option, Vim can act as a command server. It accepts messages from a client and executes them. At the same time, Vim can function as a client and send commands to a Vim server. The following command line arguments are available: argument meaning --remote [+{cmd}] {file} ... --remote Open the file list in a remote Vim. When there is no Vim server, execute locally. There is one optional init command: +{cmd}. This must be an Ex command that can be followed by "|". The rest of the command line is taken as the file list. Thus any non-file arguments must come before this. You cannot edit stdin this way --. The remote Vim is raised. If you don't want this use vim --remote-send "<C-\><C-N>:n filename<CR>" --remote-silent [+{cmd}] {file} ... --remote-silent As above, but don't complain if there is no server and the file is edited locally. --remote-wait [+{cmd}] {file} ... --remote-wait As --remote, but wait for files to complete (unload) in remote Vim. --remote-wait-silent [+{cmd}] {file} ... --remote-wait-silent As --remote-wait, but don't complain if there is no server. --remote-tab --remote-tab Like --remote but open each file in a new tabpage. --remote-tab-silent --remote-tab-silent Like --remote-silent but open each file in a new tabpage. --remote-tab-wait --remote-tab-wait Like --remote-wait but open each file in a new tabpage. --remote-tab-wait-silent --remote-tab-wait-silent Like --remote-wait-silent but open each file in a new tabpage. --servername --servername {name} Become the server {name}. When used together with one of the --remote commands: connect to server {name} instead of the default (see below). The name used will be uppercase. If using the socketserver, you can specify a path, see socketserver-name for more details. --remote-send --remote-send {keys} Send {keys} to server and exit. The {keys} are not mapped. Special key names are recognized, e.g., "<CR>" results in a CR character. --remote-expr --remote-expr {expr} Evaluate {expr} in server and print the result on stdout. --serverlist --serverlist Output a list of server names. --clientserver --clientserver {method} Use the specified method {method} as the backend for clientserver functionality. Can either be "socket" or "x11". {only available when compiled with both +X11 and +socketserver features} Examples Edit "file.txt" in an already running GVIM server: gvim --remote file.txt Edit "file.txt" in an already running server called FOOBAR: gvim --servername FOOBAR --remote file.txt Edit "file.txt" in server "FILES" if it exists, become server "FILES" otherwise: gvim --servername FILES --remote-silent file.txt This doesn't work, all arguments after --remote will be used as file names: gvim --remote --servername FOOBAR file.txt Edit file "+foo" in a remote server (note the use of "./" to avoid the special meaning of the leading plus): vim --remote ./+foo Tell the remote server "BLA" to write all files and exit: vim --servername BLA --remote-send '<C-\><C-N>:wqa<CR>' SERVER NAME client-server-name By default Vim will try to register the name under which it was invoked (gvim, egvim ...). This can be overridden with the --servername argument. If the specified name is not available, a postfix is applied until a free name is encountered, i.e. "gvim1" for the second invocation of gvim on a particular X-server. The resulting name is available in the servername builtin variable v:servername. The case of the server name is ignored, thus "gvim" and "GVIM" are considered equal. Note if a socket server is being used, there are some differences, see socketserver-differences. When Vim is invoked with --remote, --remote-wait or --remote-send it will try to locate the server name determined by the invocation name and --servername argument as described above. If an exact match is not available, the first server with the number postfix will be used. If a name with the number postfix is specified with the --servername argument, it must match exactly. If no server can be located and --remote or --remote-wait was used, Vim will start up according to the rest of the command line and do the editing by itself. This way it is not necessary to know whether gvim is already started when sending command to it. The --serverlist argument will cause Vim to print a list of registered command servers on the standard output (stdout) and exit. If a socket server is being used, there are caveats, see socketserver-differences. {server} The {server} argument is used by several functions. When this is an empty string then on Unix the default server name is used, which is "GVIM"