TransWikia.com

Use pipe symbol as separator in statusline

Vi and Vim Asked by user419050 on August 31, 2021

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

One Answer

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+=%<
set statusline+=%=
set statusline+=%y
set statusline+= \| %{&enc}
set statusline+= \| %c:%l

enter image description here

Correct answer by Maxim Kim on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP