Your Linux Data Center Experts

During the course of a work day I often find myself reviewing several documents. As a part of our internal processes we note in these documents when they're reviewed by appending our name and the date to a list of reviewers. As you can imagine, this gets boring when adding it manually. Vim has the ability to make this much simpler.

Here's the macro from my ~/.vimrc:

nnoremap A mike strftime(“%Y-%m-%d”)s/\s+/ /:noh

Hitting F4 while in control mode will append mike 2011-04-26 to the current line, replace multiple whitespace to a single whitespace on the same line and tell vim to not highlight that match afterwards.

I have a slightly different macro to print the same date string at the current cursor position while in input mode, also bound to F4:

inoremap strftime(“%Y-%m-%d”)

This will keep me in input mode also. Having these two macros bound to the same key helps me to have to remember less which is a good thing.

comments powered by Disqus

Join our other satisfied clients. Contact us today.