On (12:28 14/11/06), A.J.Mechelynck <[EMAIL PROTECTED]> put forth the proposition: > David Woodfall wrote: > >I would like to make a command that would insert at cursor todays date, > >and also a command to insert some custom text. > > > >In the help file it shows how to make a keybind to do this but I would > >rather use a command - eg :date > > > >Can this be done? > > > >Thanks > > (untested; requires strftime() function) (note all user-defined command > names must start with an uppercase letter) > > command -nargs=* -bar Date call InsertDate(<q-args>) > function InsertDate(format) > if ! exists('*strftime') > echoerr 'strftime() not defined' > return -1 > endif > let f = a:format > if f == "" > let f = '%c' > endif > exe "normal a\<C-R>=strftime(" . f . ")\e" > endfunction > > then > :Date > will insert the current date and time in your locale-dependent default > format; or > > :Date %d %b %Y > > will (today) insert > > 14 Nov 2006 > > I hope I'm not just doing your homework (this sounds like a classical > exercise).
Thanks for the ideas. No this isn't homework - today I was writing some readmes and thought it would save some typing to make a command to print 'Release date dd mmm yyyy' > > The simplest way to insert some custom text is to keep in a register: > > let @w = "David Woodfall " > > then hit > > "wp > > to insert your name at the cursor in Normal mode, or > > ^Rw > > (where ^R means "hit Ctrl-R") in Insert mode. > > > Best regards, > Tony. -- Avoid reality at all costs.