tags:

views:

348

answers:

5

By default, I think my vimrc setttings enable the auto-wrapping. However, sometimes, I would like to see text lines are not wrapped. Is there any command I toggle the text line wrapping enabled and disabled? This would avoid me to exit and to change settings.

+1  A: 
:set nowrap

There is also the linebreak option that controls whether wrapped text is broken at word boundaries or not.

Greg Hewgill
A: 

The quickref suggests (no)wrap

toolkit
+2  A: 

In your vimrc, create a function such as this:

:function ToggleWrap()
: if (&wrap == 1)
:   set nowrap
: else
:   set wrap
: endif
:endfunction

Then map a key (such as F9) to call this function, like so:

map <F9> :call ToggleWrap()<CR>
map! <F9> ^[:call ToggleWrap()<CR>

Whenever you press F9, it should toggle your wrapping on and off.

m0j0
map <F9> :set wrap!<cr>
Jeremy Cantrell
I prefer this one. Great!
David.Chu.ca
If you like my suggestion, then you know what you must do... wink wink nudge nudge (hint: my answer is listed below)
Jeremy Cantrell
+4  A: 

I think what you want is:

:set wrap!

This will toggle line wrapping.

More about using ! (bang) to alter commands can be found at:

:help :_!
Jeremy Cantrell
A: 

That's all great solutions. Thank you very much! One thing I realized that the scroll bar for horizontal scroll does not appear event there are some long lines beyond the screen. Maybe there is a different command to make it visible?

David.Chu.ca
`:set guioptions+=b`; see also `:h gui-scrollbars`
Brian Carper