ウィンドウIDが理解できてきたので、次はwin_gotoid使います。
ヘルプです。
win_gotoid({expr}) *win_gotoid()*
Go to window with ID {expr}. This may also change the current
tabpage.
Return 1 if successful, 0 if the window cannot be found.
成功すると1、失敗すると0が返るんですね。
使ってみます。
/tmp $ rm test*
/tmp $ for i in {1..5};do echo HELLO$i>test_$i.txt;done
/tmp $ vim test_*.txt
:echo win_getid()

win_gotoで今見えているウィンドウのID、1000を指定してみましょう。
戻り値を見るためにechoを使います。
:echo win_gotoid(1000)
1が表示されたので、成功ですね。
次は、存在しないウィンドウIDを指定してみます。1005を指定してみます。
:echo win_gotoid(1005)

0が表示されたので、失敗です。


コメント