By default, I’ve got Vim set up to not word wrap. While this is useful for writing code, it sometimes is a nuisance when writing notes or posts for my site as the sentences are cut off past the current view.
Toggling is pretty straightforward in Vim, so in instances in when I do need the copy in front of me to be word wrapped I could turn it off and then quickly turn it off again.
Command to turn on word wrap in Vim
To turn on word wrap in Vim, you’ll want to enter this sequence of characters in normal (command) mode:
This will immediately word wrap all the sentences in the current document that is open in the buffer.
Command to turn off word wrap in Vim
To turn off word wrap in Vim in the current document that is open, you’ll want to enter this sequence of characters in normal (command) mode:
Command to toggle word wrap in Vim
:set wrap will turn on word wrap in Vim and
:set nowrap will turn off word wrapping, you can also use both commands with the
! (bang) symbol to toggle word wrap.
So using either:
Will both toggle word wrap in the current document in the buffer.