Creating Custom Command in vi

I am using vi for almost everything, and i always comment before my changes. I prefer to comment like this:

# ebal, Wed Oct 13 14:20:46 EEST 2010

so i usually type:

# ebal,
: r! date

I was loosing too much time with that, so i’ve searched in google for a custom shortcut in vim to do exactly the above by hitting a special key.

After a while i found the solution!

In the end of /etc/vimrc i put the below map vi command:

:map <f1> :r! export -p LC_ALL=C; echo "# `whoami`, `date`"<return>
  1. Avatar di Christos Christos

    Thursday, October 14, 2010 - 11:01:12

    I would advice to use ~/.vimrc and not the global /etc/vimrc. :-)

  2. Avatar di Chris Chris

    Saturday, October 16, 2010 - 02:45:59

    Vim != Vi