Published 16 January 2011
Before I started using vim, my main text editor was the e-text editor. Now that I've been using vim for a while, I have no desire to go back to e, but I still miss one feature -- smart indenting on line wrap. When typing in e if my text wrapped around to the next line it would automatically be indented at the level of the previous line. In vim, when a line wraps, it is never indented. You can handle this by putting in hard line breaks, but then if you need to cut and paste your test anywhere you end up reformatting it all the time. I prefer smart indenting that I don't have to mess with.
Here is an example of the vim behavior that irritates me (see line 6):

And here is the way I like it to be:

Luckily I'm not the first person that has wanted this. Václav Šmilauer developed a patch that has been updated by Eli Carter. There is no way to use this in the default vim distribution, but if you build vim from source you can add in this break indent patch.
Following is my documentation on how to build Vim from source on Ubuntu 10.04 LTS Lucid Lynx with this patch included.
Make sure you have mercurial installed:
sudo apt-get install mercurial
Get the dependencies necessary to build vim
sudo apt-get build-dep vim-gnome
Download the vim source code:
cd /tmp hg clone https://vim.googlecode.com/hg/ vim
Download the patch from Eli Carter's retractile.net and place it in /tmp/vim/
Apply the patch
cd /tmp/vim patch -p1 < vim-7.3-breakindent.patchNote the -p1 option tells patch to ignore the first slash and anything before it in the file name designated in the vim-7.3-breakindent.patch file. This lets you can name the repository whatever you want.
Build vim
make sudo make install
Remove unnecessary files created during the build.
make distclean
If you already had vim on your system, make sure you are running the correct version:
/usr/local/bin/vim
Turn on the break indentation in vim
:set bri
Set your Gnome menu to use the new vim.
Note the -f is a gvim option that causes it to run in the foreground. The %F is a Desktop Entry field code that causes it to take a list of file names.
In your shell's startup file (e.g., ~/.bashrc or ~/.zshrc) add an alias so when you call vim you get your new version.
alias vim='/usr/local/bin/vim'
Copyright 2000-2008 Jason Anderson.
Powered by Django, Photologue and Galleria.