Единственное, что я могу придумать для этого, это использовать :windo
, чтобы перебрать все окна в текущей вкладке и проверить, загружен ли файл. Как то так:
function! TabIsEmpty()
" Remember which window we're in at the moment
let initial_win_num = winnr()
let win_count = 0
" Add the length of the file name on to count:
" this will be 0 if there is no file name
windo let win_count += len(expand('%'))
" Go back to the initial window
exe initial_win_num . "wincmd w"
" Check count
if win_count == 0
" Tab page is empty
return 1
else
return 0
endif
endfunction
" Test it like this:
echo TabIsEmpty()
" Use it like this:
if TabIsEmpty() == 1
echo "The tab is empty"
else
echo "The tab is not empty"
endif
Если открыта только страница справки, окно предварительного просмотра или что-то в этом роде, вероятно, он вернет 1, поскольку я не думаю, windo
работает над ними.