From 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
Place cursor under 10 and press Ctrl+A to increase the time as shown below:
- 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.
Press Ctrl+A to increase roman number as shown below:
Note: To decrease Roman number press Ctrl+X.
Get the Linux Sysadmin Course Now!