How do I add a per-window title bar showing the current file name in Neovim?
Answer
set winbar=%f
Explanation
Neovim 0.8 introduced the winbar option: a line displayed at the top of each window, separate from the global statusline. Unlike the statusline (which can only show one window's information at a time), winbar renders independently for every split, making it easy to track which file each panel contains at a glance.
How it works
winbar accepts the same %-escapes as statusline:
%f— relative file path (most compact)%F— full file path%t— filename only (tail)%m— modified flag ([+]when unsaved)%r— readonly flag ([RO])%=— separator (right-align everything after this)%l:%c— line and column number
A practical configuration that shows the filename left-aligned and line/column right-aligned:
set winbar=%f\ %m%=%l:%c
Or, using Neovim Lua (init.lua):
vim.opt.winbar = "%f %m%=%l:%c"
Example
With set winbar=%t %m and two vertical splits open, each split displays its own filename above its content — for instance server.go [+] on the left and client.go on the right — even while the status line at the bottom only shows information for the focused window.
Tips
winbaris a global-local option: set it globally and then override it per-window withsetlocal winbar=(empty string) to hide it for specific windows such as file trees or quickfix panels- Use
%{fnamemodify(expand('%'), ':~:.')}for a path relative to the home directory, similar to how many terminals truncate long paths - Pair with Neovim's
nvim_set_decoration_providerorBufWinEnterautocmds to populatewinbardynamically with LSP breadcrumbs or git branch information winbarrequires Neovim 0.8 or later; it is not available in Vim