Vim + tailwind incrementing numbers

Viewed 31

When using tailwind, there are many utility classes like px-1, py-1 etc. When using Ctrl+a to increment px-1, it becomes px0. How can I make Ctrl+a on px-1 become px-2 instead?

2 Answers

Don't. The -1 in px-1 is recognized as a negative number so incrementing it can only turn it into a 0.

Instead, use <C-x> to decrement it to -2 or follow this suggestion, found a few screens below :help ctrl-a:

For decimals a leading negative sign is considered for incrementing/
decrementing, for binary, octal and hex values, it won't be considered.  To
ignore the sign Visually select the number before using CTRL-A or CTRL-X.

vim sees px-1 as px and -1. To make it -2 you don't want to increment it (-1 + 1 = 0), you want to decrement (-1 - 1 = -2).

The command to decrement is Ctrl+X: docs.

Related