Wrapping Lines in Vim at Character or Word Boundaries

Benjamin Porter
2 min readFeb 24, 2022

I have my ~/.vimrc file set up to enable wrapping lines at word boundaries instead of characters, and this is usually the behavior I want. However, occasionally I want to copy/paste some content from a file and I don’t want the extra spaces that vim adds for visual appeal to be there. This leads me on the same exercise of ducking for how to configure line wrapping in vim, not finding what I need, and digging through the :help until I find it. I’ve had it and I’m just creating the article I need, and hopefully next time when I search for “how to wrap lines at character boundaries” this will come up!

TL;DR:

Turn on wrapping at word boundary:

Turn on wrapping at character boundary:

Turn off all wrapping (Back to default settings):

Deeper Explanation

In my ~/.vimrc file I do two things that matter here:

:set wrap will turn on wrapping. Without this, when a line exceeds the width of the window, it will continue on off screen. Sometimes this is desirable (such as when viewing code that doesn’t follow line length limitations), but usually it is not. Usually it’s easier to read when wrapped.

However, by itself :set wrap will cause the wrap to occur at the character, like this:

--

--

Benjamin Porter

Ben Porter is a Software Engineer/Architect who specializes in distributed applications (like web apps). He is currently Head of Engineering at Ameelio.org