I am trying to get some sort of unique identifier for a window, so that commands can be run against that window.
Ie, if i need to give that window focus.. or if i need to see the size of that window.. etc. The problem is currently it seems like the window number is used as this identifier, but this number potentially changes any time a new window is introduced.. It seems like it is an index count from left to right and top to bottom.. which puzzles me as to why that would be used as an identifier.
Seeing as i have no idea what the user may do to a layout.. how can i assure that when i assign a window a buffer, or get information about a window, that the i am actually getting information about the window i want?
Recent Vim versions have
win_getid()function andwin_id2tabwin()in place of the belows:FindWinID. Alsowin_gotoid()to just go to window with given identifier. Identifiers are maintained by Vim itself, so even opening window with e.g.noautocmd wincmd swill not be able to create a window without an identifier.For older versions, you can use window variables to get such identifier:
This should mark all windows. Or, it is maybe better to mark only that windows which you want to use just after window creation. To find a window with id
abcand then switch to it: