To search a buffer in vim, you can just type “/”, followed by the search term, right? But what about searching for expressions or variable values? This is an out-of-the-box feature of the substitute command, but doesn’t work for the “/” search.

The solution is simple. First, build the command that you’d like to execute as a string:

"/".strftime('%a, %d %b %Y')

This will result in a string like this:

/Sa, 22 Feb 2014

The “/” tells vim to start searching. The strftime function call returns the current date. The dot in between is used for concatenation.

Now, the exec (:help exec) command can be used to evaluate and execute the command:

:exec "/".strftime('%a, %d %b %Y')

To search for the current date with just a few keystrokes, a custom mapping can be used (in .vimrc; hit Leader + D):

map D :exec "/".strftime('%a, %d %b %Y')