How do I add a per-window title bar in Neovim that shows context like the current filename?
Answer
:set winbar=%f
Explanation
Neovim 0.8 introduced the winbar option, which adds a title bar at the top of each window — independently per split. Unlike statusline (which is shared at the bottom), winbar is attached to the window itself, so each split has its own title. This is ideal for showing filenames, breadcrumbs, or diagnostic information when you have many splits open.
How it works
winbaruses the same format strings asstatusline(e.g.,%ffor filename,%mfor modified flag)- It is window-local — each split can display different content
- Set it globally with
:set winbar=...or per-window with:setlocal winbar=... - Plugins like
barbecue.nvimorlualineusewinbarto show LSP breadcrumbs
Example
" Show filename and modified flag in every window's title bar
:set winbar=%=%f\ %m
With three vertical splits open, each split top now shows its own filename:
src/main.go [+]
─────────────────────────────────────────
...buffer contents...
Tips
- Use
%=to right-align or center content within the winbar - Combine
%f(relative path),%F(full path), and%m(modified flag) for a compact display - Set to empty string
''to hide the winbar for specific buffers (e.g., terminals or floating windows) using an autocommand - In Lua:
vim.opt.winbar = "%=%f %m"for the same effect