sponsor Vim development Vim logo Vim Book Ad

speeddating.vim : Use CTRL-A/X to increment dates, times, and more

 script karma  Rating 196/75, Downloaded by 7870  Comments, bugs, improvements  Vim wiki

created by
Tim Pope
 
script type
utility
 
description
Take the following date:

1999-12-31

Because Vim treats the hyphen as a negative sign, pressing CTRL-A on the 31 would normally increment it to

1999-12-30

Compare this with what happens when speeddating.vim is installed:

2000-01-01

Pressing 5<C-X> on the 03 in the first line below transforms it into the second:

Sat, 01 Jan 2000 00:00:03 +0000
Fri, 31 Dec 1999 23:59:58 +0000

Several date, time, and datetime formats are included.  Additional formats can be defined in a strftime-like syntax with the :SpeedDatingFormat command.

Existing Vim semantics are preserved.  CTRL-A and CTRL-X accept a count, and plain number incrementing is used if no date format is matched.

Use of CTRL-A/X in visual mode enables incrementing several lines at once.  Blank spots are filled by incrementing the match from the previous line, allowing for creation of sequences (1, 2, 3; 2000-10-30, 2000-10-31, 2000-11-01).

Can also increment roman numerals and ordinals (1st, 2nd, 3rd, ...).  In visual mode, letters of the alphabet are supported.

d<C-A> sets the timestamp under the cursor to the current time.  d<C-X> does the same, but uses UTC rather than the local time.

The "." command will work as expected if you install repeat.vim, vimscript #2136.

Feedback wanted: speeddating currently supports locale dependent day/month names/abbrevations, but also includes English abbreviation support.  However, most of the built-in formats just use the English version, because it is either mandated by a standard (like RFC 822) or because they are typically used in an international context (like the Last Change: header in Vim scripts).  Is it even worth supporting the locale dependent names at all?  Is anyone actively using them?

http://github.com/tpope/vim-speeddating
 
install details
Extract in ~/.vim (~\vimfiles on Windows).
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
speeddating.zip 20150124 2015-01-24 7.0 Tim Pope Convert to use autoload file.
Support milliseconds on %k.
Add default formats for date -Im.
Respect nrformats without octal in visual mode.
Fix for selection=exclusive.
Fix current time retrieval on Windows.
speeddating.zip 20100301 2010-03-01 7.0 Tim Pope Fix hanging when incrementing a month across a year boundary.
speeddating.zip 20100219 2010-02-19 7.0 Tim Pope Real documentation file.
CTRL-X on March 31 yields February 28 not March 3.
speeddating.vim 20081016 2008-10-16 7.0 Tim Pope Fix false positives on patterns with periods
speeddating.vim 20080314 2008-03-14 7.0 Tim Pope Basic timezone support.
Formats like "Fri Mar 14" are smartly incremented, rather than assuming the year 2000.
Fixed error when wrapping down that would result in things like 23:60:60.
speeddating.vim 20080129 2008-01-29 7.0 Tim Pope Integer treated as unix timestamp with maps for current time.
%* at beginning/end of pattern suppresses \</\>.
%0x in a pattern is %x with mandatory leading zeros.
Three new default formats.
speeddating.vim 20080120 2008-01-20 7.0 Tim Pope Removed days of week.  They may be added back if desired with :SpeedDatingFormat (%A is full name, %a is abbreviation).
Roman numerals are now just a special year format.  They can be disabled with :SpeedDatingFormat! (%^v for uppercase, %v for lowercase).
Changed default "now" mappings to d<C-A> and d<C-X>.
Bug fixes, mostly concerning visual mode.
speeddating.vim 20080111 2008-01-11 7.0 Tim Pope Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github