I want to search for all integers in a file inside Vim session only without having to worry about the number of digits in the integers.
Sample file below.
aekv 27bc1 97 print
uint32 genid;
1hd solo 20941 h1xl
1
lev 87; rex
8h fp0 4U 2
Search should put cursor at start of any of the below integers only:
97
20941
1
87
2
/\<[0-9] helps with words starting with a digit alright.
But beyond that I am add mode to search for integers with any number of digits, I have tried with multiple combinations of \w, \d, etc.
Note: This is a precursor action for a substitute operation that adds a suffix U to all integers, so that they are treated as unsigned integers.
You can use this regex to find strings of only digits in your file:
This matches:
\<: a left word boundary\d\+: one or more digits - note that in vim regex+(one or more) must be preceded by\\>: a right word boundary