Proper word-wrapping in vim

That last post took hours to put together, so this one will be short and brief. A long time ago I found two settings for vim that, when used in conjunction, give me the word wrapping I need when I compose these posts from within Charm. I never made a note of them, which is bad form.

The problem is something I’ve talked about before, so I’ll spare you the long and boring reason for needing that behavior. Under Crux, the plain-jane vim that gets built doesn’t word-wrap; instead, words are simply broken at the end of the line. Nothing wrong with that, but with

set formatoptions=l
set lbr

in my .vimrc, words break at spaces or hyphens, and links break at slashes or hyphens. It’s a very nice adjustment, particularly if you want vim to behave a little more like a word processor, and not so much like a text editor. Not that there’s anything wrong with that. :)

About these ads

7 Responses to “Proper word-wrapping in vim”


  1. 1 stephen 2009/08/27 at 1:05 AM

    so is there a way to have j/k move you up and down within the wrapped line?

  2. 2 K.Mandla 2009/08/27 at 1:14 PM

    Not that I know of, but I usually use the w and b keys in command mode to move quickly around a line.

  3. 3 Jon-Michael Deldin 2009/08/27 at 11:37 PM

    Stephen: Use `gj` and `gk` to move up and down a wrapped line.

  4. 4 stephen 2009/08/28 at 11:46 AM

    Jon-Michael: Thanks so much! that’s perfect, and you can vimrc the heck out of it, even:

    nnoremap k gk
    nnoremap j gj

  5. 5 Winston 2010/08/17 at 10:47 AM

    How is it that I spent hours after a vim tutorial trying to figure out how to do just this, and now, months later, finally stumble upon it?

    Love this blog, by the way. Can’t understand half the stuff you’re talking about but the other half has come in handy, particularly with my ten year old Sony Vaio.


  1. 1 Blasphemer! DOSBox and Word 5.5 « Motho ke motho ka botho Trackback on 2010/08/17 at 9:17 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Welcome!



Visit the Wiki!

Some recent desktops


May 6, 2011
Musca 0.9.24 on Crux Linux
150Mhz Pentium 96Mb 8Gb CF
 


May 14, 2011
IceWM 1.2.37 and Arch Linux
L2300 core duo 3Gb 320Gb

Some recent games


Apr. 21, 2011
Oolite on Xubuntu 11.04
L2300 core duo 3Gb 320Gb

Enter your email address to subscribe to this blog and receive notifications of new posts.

Join 405 other followers

License

This work is licensed under the GNU Free Documentation License. Please see the About page for details.

Blog Stats

  • 3,957,873 hits

Archives


Follow

Get every new post delivered to your Inbox.

Join 405 other followers

%d bloggers like this: