Increment numbers

Vim can increment and decrement numbers while in normal mode:Ctrl-a – Increment the next number on the lineCtrl-x – Decrement the next number on the lineIn older versions of Vim, these required placing your cursor on the number. But modern Vim will automatically jump your cursor to the next occurrence of a number and perform the increment or decrement in one operation. Since any action in Vim can be prepended with a number x to perform that action x times, you can, for example, add 5 to the next number with 5<c-x>.If you’ve already internalized Ctrl-a and Ctrl-x for incrementing numbers, awesome! You might want to power up your efficiency even further with a few plugins:Tim Pope’s speeddating.vim plugin allows incrementing of dates. Instead of Vim seeing 2020-09-30 as one positive and two negative numbers, Vim with Speed Dating will understand this is a date and will properly increment the date when your cursor is on the 30, even rolling over to the next month when needed. Speed D…
Related Topics: