≡ Menu

Vim Editor: How To Increase or Decrease Date, Time, Roman Number and Ordinals

Vim editor Increment or Decrement Numbers and DateFrom Vim editor, move your cursor to a number and press Ctrl+A to increase the number or Ctrl+X to decrease the number.

  • Ctrl+A to increase the number under cursor
  • Ctrl+X to decrease the number under cursor


Ctrl-A and Ctrl-X will work only on numbers. However using Speeddating Vim plugin, you can use Ctrl+A and Ctrl+X in Vim editor to increase or decrease Date, Time, Roman Number and Oridinal Numbers.

2 Steps to Install speeddating.vim

Step 1: Download the latest version of the plugin from vim.org

Download the plugin from vim.org

$ cd /usr/src
$ wget -O speeddating.vim http://www.vim.org/scripts/download_script.php?src_id=9356

Step 2: Install the Speed Dating vim plugin

$ mkdir ~/.vim # if the directory does not exist already

$ cd ~/.vim/plugin/

$ cp /usr/src/speeddating.vim .

Usages of Speeddating Vim Plugin

1. Increase or Decrease Date Inside Vim Editor

Assume that in the following text, it should really be July 1st, instead of Jun 30th.

On June 30th, 2009 we have published Top 5 Best Linux Text editors post.
Vim took the first place with a huge margin.

Move your cursor to “June 30th, 2009” and press Ctrl+A, which will automatically increment the date to “July 1st, 2009”.

On July 1st, 2009 we have published Top 5 Best Linux Text editors post.
Vim took the first place with a huge margin.

Note: To decrease the date press Ctrl+X.

2. Supported Date Formats for Speeddating Vim Plugin

Speed dating plugin supports following date format.

  1 %i, %d %h %Y %H:%M:%S %z         Tue, 22 Sep 2009 16:06:21 +0000
  2 %i, %h %d, %Y at %I:%M:%S%^P %z  Tue, Sep 22, 2009 at 04:06:21PM +0000
  3 %a %b %_d %H:%M:%S %Z %Y         Tue Sep 22 16:06:21 UTC 2009
  4 %a %h %-d %H:%M:%S %Y %z         Tue Sep 22 16:06:21 2009 +0000
  5 %h %_d %H:%M:%S                  Sep 22 16:06:21
  6 %Y-%m-%d%[ T_-]%H:%M:%S %z       2009-09-22 16:06:21 +0000
  7 %Y-%m-%d%[ T_-]%H:%M:%S%?[Z]     2009-09-22 16:06:21
  8 %Y-%m-%d                         2009-09-22
  9 %-I:%M:%S%?[ ]%^P                4:06:21PM
 10 %-I:%M%?[ ]%^P                   4:06PM
 11 %-I%?[ ]%^P                      4PM
 12 %H:%M:%S                         16:06:21
 13 %B %o, %Y                        September 22nd, 2009
 14 %d%[-/ ]%b%1%y                   22-Sep-09
 15 %d%[-/ ]%b%1%Y                   22-Sep-2009
 16 %Y %b %d                         2009 Sep 22
 17 %b %d, %Y                        Sep 22, 2009
 18 %^v                              MMIX
 19 %v                               mmix

All of the above formats are treated as date and time format, which will automatically change the Day of the week, Month and time appropriately.

By placing cursor, and pressing CTRL+A can increase the following.

  • You can change the date.
  • You can change the Year.
  • You can change the time.

Note: It increments ordinals also such as 1st to 2nd when ctrl+A is pressed on that word.

3. Define Custom Format for Speed Dating Vim Plugin

Use :SpeedDatingFormat to define custom format. All formats shown in man strftime is acceptable for custom format.

$ man strftime

$ vim project.txt

:SpeedDatingFormat [your-custom-format]

4. Increase or Decrease Time Using Vim Speeddating Plugin

Before Ctrl+A:

10:22 AM

Place cursor under 10 and press Ctrl+A to increase the time as shown below:

11:22 AM

Note:

  • When time crosses the 24 hours, it also increases the date automatically.
  • To decrease the time press Ctrl+X.

5. Increase or Decrease Roman Numbers

Move your cursor under a roman number and press Ctrl-A.

Before Ctrl-A:

III

Press Ctrl+A to increase roman number as shown below:

IV

Note: To decrease Roman number press Ctrl+X.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • ged October 12, 2009, 3:08 pm

    Thanks for article, all works nice except one thing. Increasing/decreasing of numbers at date goes incorrectly. For example next date for June 30th is June 31th, 32th and so on. Also I found out that there are dates like -1 June 🙂 Any other increasing/decreasing, like ones for Roman numbers works like a charm, only this one broke a nice image. Any suggestions?

  • SathiyaMoorthy October 26, 2009, 9:52 am

    @ged

    It is a simple misunderstanding.

    Check whether you have that kind of format in #2: Supported Date Format. There is no such format so you should add the format, “:SpeedDatingFormat %B %o”. After adding, if you increment June 30th, it will be increased to July 1st, and so on.

  • ged October 26, 2009, 12:16 pm

    @SathiyaMoorthy
    Thanks for advice… But neither it, nor reading explanation at plugin’s page doesn’t works for me. Anyway I can live without it, just want to point out that such kind of problem exist.