I’m using vsc and I want to convert any number found to fixed 4 digits length using zero padding . For example :
2 -> 0002
99 -> 0099
Can I use find and replace ? or any extension ?
Thanks
I’m using vsc and I want to convert any number found to fixed 4 digits length using zero padding . For example :
2 -> 0002
99 -> 0099
Can I use find and replace ? or any extension ?
Thanks
2
Answers
if you want to change the numbers in a file you can use the extension I wrote Regex Text Generator
Ctrl+F
.*
buttond+
Alt+Enter
(.*)
{{N[1]:size(4)}}
Return
if you see what you like orEscape
Very easy to do with an extension I authored, Find and Transform.
Make this keybinding (in your
keybindings.json
):The
"find": "\b(\d{1,4})\b",
assumes your numbers are not within other text, likeblah123blah
.If you want to handle the
blah123blah
case ->blah0123blah
, then use the simple:"find": "(\d+)",
Demo using the simple
"find": "(\d+)",
version: