I wanted to make my own status line and I wonder how can I use a pipe as a separator? I want to achieve something like this:

NORMAL | file.html [html] | utf-8 | 80:10

1 Answer 1


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'

set statusline=%{VimMode()}\ \\|
set statusline+=\ %f
set statusline+=%<
set statusline+=%=
set statusline+=%y
set statusline+=\ \\|\ %{&enc}
set statusline+=\ \\|\ %c:%l

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.