To add a pipe, escape it with double \\|: func! VimMode() abort let md = mode() if md == 'n' return 'NORMAL' elseif md == 'v' return 'VISUAL' else " check mode() help to define other mode names here return 'OTHER' endif endfunc set statusline=%{VimMode()}\ \\| set statusline+=\ %f set statusline+=%< ...


The easiest way would be to call git inside %{} like so: let &statusline = '%{substitute(system("git status -s"), "\n", " ", "g")}' Anything inside %{} get evaluated as an expression, and here we call git status -s with system() and replace newlines with a space, resulting in a statusline like: ## repl M db.go ?? ...


This can be done much more simply with the expand() command: function! SetStatusLinePath() return expand("%:h") . "/" endfunction function! SetStatusLineFile() return expand("%:t") endfunction set statusline+=%#pwd#%{SetStatusLinePath()} set statusline+=%#file#%{SetStatusLineFile()} see :h expand()

Only top voted, non community-wiki answers of a minimum length are eligible