The documentation say:
When the option starts with "%!" then it is used as an expression,
evaluated and the result is used as the option value. Example:
The g:statusline_winid variable will be set to the window-ID of the
window that the status line belongs to.
So if you for example do:
return "WID: " . g:statusline_winid
Your status-line will be:
NNNN is the window-ID. Or put another way: the variable
g:statusline_winid is not set unless you use a call with
Also note that the variable is unset after function exits.
winid vs winnr
As for what it is:
winid: Each window has it's own ID. When you start Vim first window typically has ID
1000. If you open a new window by e.g.
:split the new window get ID
1001 if you close that split and open another that get
winnr: Each window has a number based on it's position. Upper left is 1. You can for example have:
| | 2 |
| 1 +-----+
| | 3 |
| | |
winnr is not persistent. It all depends on the layout. If you close window number
1 in example above, 2 becomes 1 and 3 becomes 2.
winid is a way to keep track of a window independent of layout changes.