Reputation: 38634
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.
Upvotes: 31
Views: 12592
Reputation: 4663
I happen to like tpope’s unimpaired plugin, where yow
will toggle wrap settings.
Upvotes: 1
Reputation: 491
For those who want to change the text instead of just visual effect, for example in git commit, just press qt
in a roll and press enter. This will properly wrap the current paragraph your cursor is in. The paragraph is only delimited by blank lines. or you can select some area to press qt
.
I found this by total accident.
Upvotes: 0
Reputation: 15775
Add the following to have CTRL+W toggle wrapping. You can change it to some other key if you don't want w
to be it.
map <C-w> :set wrap!<CR>
Upvotes: 6
Reputation: 27416
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 :_!
Upvotes: 63
Reputation: 3864
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.
Upvotes: 17
Reputation: 992717
:set nowrap
There is also the linebreak
option that controls whether wrapped text is broken at word boundaries or not.
Upvotes: 7