Capitalization in vim when using ctrl-a to increase

If I use ctrl-ato increase the hexadecimal number (or ctrl-xbefore decrement), the number will use lowercase letters if there are currently no other uppercase letters.

For example, if I increase 0x009, I get 0x00a, but if increment 0xA09, I get 0xA0A.

I want it to use capital letters by default. Does anyone know how to do this? Does anyone else care?

+5
source share
2 answers

One tricky way:

:nnoremap <C-A> m'<C-A>vUgUTx``

Explanation:

m'         # Create a mark on digit to increment.
<C-A>      # Control-A
v          # Visual select current letter.
U          # Set visual selection (current letter) to uppercase.
gUTx       # Set to uppercase (gU) next movement: (Tx) from current position to previous 'x' letter.
``         # Go to position of previous mark.

Thus, this method creates a slight difference from the original one <C-A>, for example, in this case:

A hex number 0x0ba in lowercase.
      ^--- Cursor position

0x0ba 0x0BB, n number, . , . , .

+5

0X 0X, Vim .

+4

All Articles