Reputation: 975
Is there a way to check if a single buffer is open in multiple windows?
For example if you open up a file and you use the :vsp
command, you can split up the current file into 2 windows, both looking at the same buffer, basically one buffer in two windows.
Single buffer:
The same buffer on two windows:
Is there a way to detect if one buffer is open in multiple windows via vimscript?
Upvotes: 5
Views: 1263
Reputation: 45177
You can use win_findbuf()
function which will take a buffer number and return a list of Window-IDs.
:echo win_findbuf(bufnr('%'))
For more help see:
:h win_findbuf(
:h winid
:h bufnr()
Upvotes: 7