Getting Soft Word Wrap in gVim and Emacs

I really don’t like most Windows text editors.  I use gVim for all of my text editing.  Everyone extols the virtues of Notepad++ and several other text editors, but they miss some basic features that really make text editing a lot more fun.  gVim lets me move around the file word-for-word without nasty Ctrl+this or that combos that require me to put my hands all over the keyboard.  I can get to very specific parts of a text file very quickly with gVim, whereas all Windows text editors force me to use the mouse.  gVim has the added bonus that it’s really rare to find a *NIX system without it, so I’m able to happily edit text on any machine.

The one thing Windows text editors always get right that I could never get gVim to do is soft word wrapping.  Notepad does this perfectly (so do web input controls.)  When you hit the end of the line, the text wraps to the next line, but when Notepad saves the file, all of the text is on one line.  gVim uses hard word wrapping by default: When you hit the end of the line in gVim, one of three things happens based on your word-wrapping options:

  1. The text scrolls and you’re in horizontal scroll unhappyland.
  2. gVim happily inserts a hard line break into your file.
  3. gVim wraps the text, but leaves a marker to indicate that this is a logical line rather than a physical line.

I hate #1.  I want to be able to see all the text in the file except in very rare circumstances.  #2 sucks when I’m writing something that’s ultimately bound for another program with no facilities for saving, like our issue tracking software; it really stinks
when all of your text has unnatural breaks because
the character width of the editor is nowhere near
as big as the web page.

This leaves #3 as the setting I use most frequently.  This gets annoying for scrolling though; my mind wants to jump from the "first" line to the "second", but this is a horizontal operation rather than the vertical operation that the display suggests.  It always takes me several tries.  I tried for a long time to find ways to get soft word wrapping in gVim, but decided it was impossible and started down the dark path of Emacs (which is actually pretty cool, but I still like gVim better!)

I found that Emacs performed much like gVim, but the way it did its wrapping like situation #3 was much more tolerable.  Still, I wanted things to work like in Notepad.  I found a blog post about enabling soft word wrapping in Emacs (M-x longlines), and it worked like a charm.  Still, I had a lot of muscle memory invested in gVim, so I decided to give it one last Google search.  gVim tip #989 is enabling word wrap without line breaks, which works like a charm.

I’m still kicking around the idea of converting to Emacs, though.  I like gVim’s "your hands shouldn’t leave the home row" philosophy, but it really seems like Emacs has better support for things like HTML and XML.

3 thoughts on “Getting Soft Word Wrap in gVim and Emacs

  1. Oh, and of course, what I really wanted to write was:

    :set lbr
    :map <Down> gj
    :map <Up> gk

    Damn lack of previews!

    Also :set fo=l could help.

Comments are closed.