Reputation: 11299
I'm new to Vim
and trying to solve what might just be a very basic thing.
When I type dd
and press <space>
in insert
mode, I want it to be replaced with [10-Feb-2011 10:10]
. (notice the square brackets around date).
So, far I've been able to achieve this - :iab <expr> dd strftime("%e-%b-%Y %H:%M")
which inserts date, but I also want it to be surrounded by square brackets.
I'm using Maemo's implementation of Vim on Nokia N900.
http://maemo.org/downloads/product/Maemo5/vim/
I'd also like to know how to make this change persistent so that the dd
abbreviation is always available in all sessions of vim. (writing this line in ~/.vim
or something like this).
Upvotes: 5
Views: 1382
Reputation: 58677
In your ~/.vimrc file:
:iab <expr> dd strftime("[%e-%b-%Y %H:%M]")
Note however that Vim uses your platform's strftime
so the string it takes and the format flags in particular are platform-dependent.
Upvotes: 7