I have had several problems with my program editor Vim recently. Here is how I fixed one of them.
There are two directories that I had to mess with:
c:\program files\vim [vim directory]
c:\users\rabbit [user directory]
the vim directory is the standard installation directory for vim in windows
the user directory is new with Windows 7, and is where you’re supposed to put config files for programs in the default installation location
When I first installed Vim 7.* on Windows XP, I put in some basic preferences in the vim directory, then promptly forgot what I had done. When I updated to new versions of Vim, these settings, such as textwidth, did not get wiped out, but instead kept on doing what I set them to do. Now that I’m on a new machine with windows 7, these modifications are gone.
Windows 7 now bans editing files in the c:\program files directory. This is supposed to improve security. This means I can’t just go into the vim directory and fix things. Instead I have to put all my config files in the user directory
This is not as simple as it sounds. One particular problem I have had is vim’s textwidth. Vim out of the box breaks lines at every 78 characters in text files. I tried just issuing the textwidth = command which should turn this off. It did not. I tried the windows way, using my old _vimrc config file from XP. This did not work. Why?
It turns out that I turned off line wrapping at the top of _vimrc file. But then I added something else, so that my _vimrc file looked like this:
So why is it still wrapping? Why can’t I just turn it off by :set nowrap, or textwidth =
The vimrc_example.vim file includes the following lines:
” For all text files set ‘textwidth’ to 78 characters.
autocmd FileType text setlocal textwidth=78
This turns wrapping back on for every new text buffer I open. I have found and forgotten this problem 3 times in the last year and a half, each time wasting as much as an hour! Definitely worth an entry here as a reminder.
To fix this, I copy only the stuff I want from vimrc_example straight into _vimrc, omit source $VIMRUNTIME/vimrc_example.vim, and voila, no more mysterious text wrapping.