vim - How to get a unique identifier for a window? -
i trying sort of unique identifier window, commands can run against window.
ie, if need give window focus.. or if need see size of window.. etc. problem seems window number used identifier, number potentially changes time new window introduced.. seems index count left right , top bottom.. puzzles me why used identifier.
seeing have no idea user may layout.. how can assure when assign window buffer, or information window, getting information window want?
you can use window variables such identifier:
" put unique window identifier w:id variable autocmd vimenter,winenter * if !exists('w:id') | let w:id={expr_that_will_return_an_unique_identifier} | endif
: should mark windows. or, maybe better mark windows want use after window creation. find window id abc
, switch it:
function s:findwinid(id) tabnr in range(1, tabpagenr('$')) winnr in range(1, tabpagewinnr(tabnr, '$')) if gettabwinvar(tabnr, winnr, 'id') a:id return [tabnr, winnr] endif endfor endfor return [0, 0] endfunction <...> let [tabnr, winnr]=s:findwinid('abc') execute "tabnext" tabnr execute winnr."wincmd w"
most recent vim versions have win_getid()
function , win_id2tabwin()
in place of s:findwinid
, win_gotoid()
go window given identifier. identifiers maintained vim itself, opening window e.g. noautocmd wincmd s
not able create window without identifier.
Comments
Post a Comment