How can I show the value of a Vim option in the status line

130 Views Asked by At

I would like my status line to display wrap/nowrap.

set statusline +=%{execute(':set wrap')}

doesn't work. How do I do this?

Thanks!

1

There are 1 best solutions below

2
j1-lee On BEST ANSWER

Try the following, which works for me:

set statusline+=%{&wrap?'WRAP':'NO\ WRAP'}

Here, I used &wrap instead of :set wrap to get the current wrap status, and escaped the space \ (if you need one).