Disable (and toggle) text wrap in vi

By default, vim will wrap lines of text that flow off the viewable screen. Normally this isn’t such a bad thing. However, when you’re editing source code or reading log files this can become annoying.
It’s fairly simple to disable this options, a simple :set nowrap will disable wrapping for the current vim session.
Placing set nowrap in youre .vimrc will disable wraping for all vim sessions.
Finally, we can use maps to create a kind of toggle switch for wrapping.
In your .vimrc add :map < F2> :set nowrap! < CR>
Now, anytime you press F2, wrapping will be toggle on and off. You can still set your default preference in .vimrc, but now you can toggle between the two settings with ease.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

This entry was posted in tips. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted July 26, 2008 at 12:12 am | Permalink

    Text wrapping really does get in my way sometimes when I’m editing scripts.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>