0

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

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

doesn't work. How do I do this?

Thanks!

Jim Bollinger
  • 1,671
  • 1
  • 13

1 Answers1

2

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).

j1-lee
  • 13,764
  • 3
  • 14
  • 26
  • Wonderful! Thank you j1-lee. Is `&wrap` a synonym for `:set wrap`? Or does it have other uses? – Jim Bollinger Sep 13 '22 at 00:39
  • @JimBollinger As far as I know, `&wrap` is a variable that stores `wrap` option. So you can do things like `:echo &wrap`, `:let &wrap = 0` etc. (`:help :let-option`) – j1-lee Sep 13 '22 at 03:01