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:
2000年1月01日 00:00:03 +0000
1999年12月31日 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
Extract in ~/.vim (~\vimfiles on Windows).
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 |