Vim screen corruption with screen/tmux and matchparen.vim

I’ve been experiencing an irritating bug for a few weeks and I finally eliminated it by disabling matchparen.vim

The bug happens when I’m using vim in an ssh session (to a Linux machine) with GNU Screen or tmux (on the server) in or on Mac OS X and editing PHP code. If I type “require dirname(__FILE__) .“, then after typing the closing parenthesis, the screen gets corrupted such that it looks like I typed “require dirnam((__FILE_))” (missing “e”). Hitting Control-L refreshes the screen of course, but it’s irritating nonetheless.

Yesterday, I got the bug to disappear by putting this in my ~/.vimrc.local (I’m using Janus):

" vim's parenthesis highlighting causes screen corruption when vim is running
" inside GNU screen or tmux?
let loaded_matchparen = 1

I don’t know if this is a bug in matchparen.vim or something else.

If I type slowly, it looks like after typing the closing parenthesis, both the opening and closing parenthesis are highlighted correctly. Things go haywire after typing a space after the closing parenthesis. It looks like it’s attempting to replace the highlighted open parenthesis with a normal parenthesis but it does it one cursor position to the left, resulting in the “e” in dirname getting overwritten with a parenthesis and the highlighted open parenthesis is still present next to it.

Here’s a screenshot:

If I understood more clearly what the problem is, then I’d try to fix it and submit a patch, but I’m not very knowledgable about terminal issues. If someone points me in the right direction, I might be able to come up with a patch…

I’ll be posting this to the vim_dev mailing list as well.

How to build MacVim with Python 2.7

The first few times I tried building MacVim, it kept linking with the system Python. I wanted it to use my Python 2.7 install. I finally found the right incantation:

./configure --enable-rubyinterp=yes --enable-pythoninterp=dynamic --with-python-config-dir=/usr/local/lib/python2.7/config

The --enable-pythoninterp=dynamic was the magic that I needed to make it work.

Editing a crontab with vim

If your vimrc is configured to use backup files and you try to invoke crontab -e (or vipw or visudo, etc.), you might get an error like this:

crontab: temp file must be edited in place

You need to make vim not do backups of temp files. An easy way to fix this is to add something like this to your vimrc file:

set backupskip=/tmp/*,/private/tmp/*

Thanks to