The Stack Overflow podcast is back! Listen to an interview with our new CEO.
22

You need vim compiled with +clientserver, and then you can use the command vim --servername SERVER to start a vim instance and vim --servername SERVER --remote FILE to open the file in the named vim instance. macOS only MacVim runs a server by default - you can use mvim --remote-tab-silent to open a file in a new tab in your existing MacVim instance, or ...


21

Before the channel/job recent feature of Vim 7.4, the client-server feature was the only way to do a decent background compilation -- without any dependency to Python. We start compilation as a background job, and when it finishes, it notifies back to vim, thanks to the client-server channel, that it has finished. It's also indirectly used by "plugins" like ...


13

My use of this is a little more simplistic (and perhaps commonplace) than Luc Hermitte's. If you start an instance of gvim with this compiled in (and it is, and has been for a long time, on, e.g., major linux distros like Fedora and Debian), it starts in server mode. I emphasized "gvim" because what I'm about to describe does not seem to apply to a singular ...


8

As far as I know vim has this feature because the GUI vim (gvim) uses the graphical X server. I am aware that non GUI Vim can also use the --servername argument but only when X11 is running and also by accessing to it. On the other hand, neovim has no graphical support; for that reason, I don't think that the --servername option can work (unless the option ...


7

You can tell a Vim server to reload the vimrc file like so: $ vim --servername MARTIN --remote-send '<Esc>:source $MYVIMRC<CR>' And you can get a list of all servers with: $ vim --serverlist MARTIN CARPETSMOKER Which can be combined with a for loop: $ for s in $(vim --serverlist); do vim --servername "$s" --remote-send '<Esc>:source $...


7

Neovim remote is a python script for controlling neovim processes. It has the vim style --servername and --remote options. This is what I use now for my multiple-terminal work environment.


5

Embedded development. A lot of times in embedded development you have a IP socket, but limited local hard drive space, or no non-volatile memory, or any number of other things. You can start a server on the embedded board, and then client into it on your development computer and have all your configuration and tags setup locally.


4

In any context where a "keycode" is expected, use <lt> to represent a literal <. vim --remote-send "<lt>C-t>" See also :help keycodes.


4

One solution (not perfect) is to use Ctrl-C instead, for example: vim --remote-send '<c-c>:echo "test"<cr>' This seems to work in command-line, normal, insert and visual mode, but not in operator-pending mode (at least in my test, after pressing va from normal mode with no timeouts).


4

As mentioned, all of the clientserver features were removed in Neovim. This is because they use the X11 shared memory and Neovim removed X11 support. However, if I use :help --servername in Neovim I end up in the documentation for the serverstart() function: serverstart([{address}]) serverstart() Opens a ...


4

While @craigp's answer is correct, I found it most convenient to simply add --remote-silent without worrying about server names,(this assumes you don't want to address named vim instances). This will start the server, or use one if its not already started. It can be called like this: gvim --remote-silent '+cal cursor(line,col)' some_file eg: gvim --...


3

The way I understood your question, you have a script which opens several tabs in a vim instance, you do stuff and end with 2 tabs opened in vim, and one of these tabs is empty. When you close the non empty tab, vim should close too since the remaining tab is useless. In this case you could use the following function + autocommand: autocmd! WinEnter * call ...


3

No idea about the clientserver feature, the simplest way I can think of would be to use the system clipboard by default when yanking or pasting which can be done with: set clipboard=unnamedplus Depending on your OS and environment, you might need other tweaks for it to work seamlessly. Also, you may be able to leverage the viminfo file (or :h shada on ...


2

Vim is able to use the same completion database if the database is external to each vim instance. For example, completion will be somewhat 'shared' if you use ctags completion or youcompleteme or any other plugin that uses external processes or files. Word completion is not quite useful for you because it will only use words in the same file: C-N/C-P But ...


2

You cannot use --remote with -q, any arguments after --remote are treated as filenames: --remote Connect to a Vim server and make it edit the files given in the rest of the arguments. If no server is found a warning is given and the files are edited in the current Vim. That said, you cannot use the result of process substitution ...


2

You could use your own code to list the buffers, instead of execute "silent buffers": for i in range(1, bufnr('$')) if buflisted(i) echo i . ' ' . fnamemodify(bufname(i), ':p') endif endfor Here fnamemodify() with ':p' will give you the full path to each filename. The check for &buflisted will avoid listing buffers which have been closed, help ...


2

I had exactly the same problem when trying to get vimtex working with Skim. That is, I had vim 8 installed with --with-client-server (showing as +clientserver) and XQuartz running but --servername option was just ignored. The solution for me was setting DISPLAY: export DISPLAY=:0.0 After that everything worked exactly as it should. Edit: help x11-...


2

LEI is right; and the neovim help instructions give this as a specific use case for that feature: Two commands can be used to read and write the ShaDa file manually. This can be used to exchange registers between two running Vim programs: First type ":wsh" in one and then ":rsh" in the other.


2

What you are looking for has nothing to do with Vim or any editor you are using, you want a tool like grunt.js. Grunt is a task runner that you can configure to do a lot of things automatically, including serving your source files, watching them and reloading the changes. There are a lot of resources online showing you how to do this and this would be out ...


2

I haven't looked deeply into it, but reading :help --remote, it mentions this about +{cmd}: This must be an Ex command that can be followed by "|". Your :normal interprets the remainder as normal mode commands; you'd need a :{cmd} to execute {cmd} as an Ex command. By wrapping this in :execute, only the quoted string is executed, and the normal mode ...


1

I tweaked an example which Ralf mentioned in the comments to get this: gvim --server=$SERVER --remote-send ":execute('tab tag $tag')<CR>" Remote send sends the following commands to the gvim server. <CR> is the return character.


1

Hack-of-concept: :autocmd CursorMoved * silent exe '!tmux send-keys Escape :' line("w0")-16: 'Enter' 'z Enter' hook into CursorMoved events (vim lacks scroll events; we could map explicit scrolls commands, like C-e, C-y) get the line at the top of the window line("w0") tell vim in the tmux session to move one screen higher than that (-16), by putting the ...


1

Atom is the only editor I know of that has that capability built-in. You'll need to bring in third party tools. I did some research on a related topic some time back as I was looking for real-time rendering of AsciiDoc markup as I typed it in (I write my work notes in AsciiDoc). The most viable editor-agnostic solution I saw was Live Reload This app watches ...


1

use tmux,tmux buffer to unname register, uname register to tmux buffer https://github.com/tracyone/t-vim/blob/master/autoload/te/tmux.vim


1

clientserver needs X11 for working. So on OSX, you have to run XQuartz. Also, be sure that your vim is not a symlink to mvim with the -v option (mvim -v would run vim in terminal mode without X11 features, from my understanding).


1

one workaround is to write an tempfile with the command(s) in them. Then send a command to source this file. like in > vim --server "<servername>" --remote-send "so /path/to/tempfile"


1

Try mutt which can open mails in vim.


1

I wrote my masters thesis using Vim, LaTeX and BibTeX. To manage my BibTeX references, I used a program called JabRef. JabRef has a neat little feature where you can connect it to a Vim server instance, and then you can "push" the BibTeX reference from JabRef to the LaTeX document that you are editing in Vim.


1

Quick and dirty way of "storing a list of open files", as requested in your comment. (I don't have enough reputation to answer a comment). :tabs gives all currently open filenames, arranged by tab number. So if you do something like command! SaveTabs :execute "redir! > tabs_" . v:servername . ".txt \ | echo v:servername strftime(\"%c\") | pwd |...


1

I found a half workaround. The trick is that if you use --remote-send instead of --remote you can make all the autocmd working. So I subsituted gvim --servername $desktop --remote-tab-silent "$file" with gvim --servername $desktop --remote-send "<ESC>:tabe $file<CR><CR>" ...and the autocmd works now. <ESC> is needed because ...


Only top voted, non community-wiki answers of a minimum length are eligible