Reputation: 1319
I have open two terminal windows say A & B.
I have vim open in my terminal A. I want to go to a terminal B and get a list of buffers currently in vim in terminal A.
Upvotes: 0
Views: 247
Reputation: 32976
You'd need to know the servername of the other vim session (it requires your vim flavour to be compiled with the right options), from there you should be able to ask whatever you wish.
To know the server name in each instance, type :echo v:servername
. You could also obtain the list of all vim servers with :echo serverlist()
.
As I read :h x11-clientserver
, as you're speaking of terminals, this means you'll need to explicitly run vim with the --servername
option -- I always use gvim when I can, so I'm not sure to know every detail in your use case. This means, you have already have to know the other servername.
Let's say you've started vim in terminal B with $> vim --servername=termB whateverotheroptions
As the list of opened buffers (not windows) can be obtained with
:echo filter(map(range(1, bufnr('$')), 'bufname(v:val)'), '!empty(v:val)')
From Vim in Terminal A, you can thus execute:
:echo remote_expr('termB', "filter(map(range(1, bufnr('$')), 'bufname(v:val)'), '!empty(v:val)')")
Upvotes: 2