The intention of the function as described in the blog post is not to toggle
relativenumber but to switch between the
In Vim 7.3, the
relativenumber settings could not be used at the same time, and I believe setting one automatically unset the other.
However, as of Vim 7.4, you can enable both settings at the same time. Doing so will use the absolute line number for the current line, and relative line numbers for all other lines.
If you don't wish to do this, and do in fact want to switch between using relative line numbers everywhere or absolute line numbers everywhere, you can amend the function accordingly:
if(&relativenumber == 1)
Alternatively, you could just leave
number on at all times, and just toggle
relativenumber, which, as grodzik has explained, you can do with a simple:
set relativenumber!. This will switch between displaying absolute line numbers everywhere, and displaying it only on the current line (with relative numbers elsewere).