Vim: persistent search buffer between vim instances (on Ubuntu)

I have two separate instances of Vim. I would like to configure my system so that when searching for something in one Vim (using / , ? , * Or # ), then press n or n in another Vim, it searches for the same something in the second Vim. I am running Ubuntu.

I already use the main system buffer for things that jerk in vim using set clipboard=unnamed in my .vimrc file.

Research so far
The xsel command-line tool allows me to access three different clipboards in Ubuntu: the main clipboard (used when you select text and click in the middle click), the clipboard clipboard (used for Ctrl + C, Ctrl + V and etc.)., and a secondary clipboard (which does not seem to be used). My thought is that Vim uses xsel to set the secondary clipboard when / , are used ? , * or # , and use xsel to access the same buffer when n or n .

+4
source share
3 answers

I was going to just publish the code I compiled for this here, but then decided to combine it into a tiny plugin: https://github.com/dahu/VimSharedSearch

+3
source

Using clipboard=unnamed set, you can copy between the registers of the last template (the last thing you were looking for), and the shared clipboard using let @/ =@ * and let @* =@ / ( * is the buffer sharing and / - last template).

So, can you create a function that copies the last template to the clipboard and maps to / ? , * or # , and the other copies the clipboard to the last template for n or n .

+1
source

Not quite what you requested, but for this purpose I use split windows ( :sp or :vsp ).

0
source

Source: https://habr.com/ru/post/1337875/


All Articles