9

I use tmux for the most part instead of using vim tabs and splits. Does vim have the ability to share completions (via Ctrln and Ctrlp) between running instances? Is there a way to set it up where each of the vims are communicating with the server vim.?

  • 8
    No, this can't be done in a practical way. Vim is perfectly capable of handling dozens and dozens of buffers, use its power. – romainl May 21 '16 at 6:18
  • 1
    @romainl, could we have something written to a "completion file" from where vim would read and refresh its completion list? – J. Chomel Jan 30 '17 at 7:38
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 omni and ctags completion will use ctags database (which should be built by exuberant ctags beforehand) and will be shared among all instances.

Type C-X C-O for omni-completion, C-X C-] for ctags completion.

0

In :help i_ctrl-n it shows that Vim uses the complete option to complete words. The help on complete goes on to show that the only real option to use something that is not local to the Vim instance is to use a dictionary file. The question then boils down to generating such a dictionary file using all vim instances. You could do this by parsing all open files every now and then. I have no idea of the impact this would have on performance though.

Another option would be to use an entirely different mechanic (ctags etc) but this might break functionality elsewhere as these were not really intended for simple autocompletion.

On a more general note, you could also change your workflow a bit to stick more to the way Vim was envisioned to be used. This would mean using one or a few windows to look at stuff simultaneously and switch buffers often. A plugin that does the switching part very nicely is ctrlP. After activating it by pressing a button it allows you to do a fuzzy search for files in various places, thereby allowing quick switching. As long as you remember the filename that is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.