Context
I use vifm
as my file manager (that's off topic here, i know, but keep reading) which allows me to edit filenames inside a vim
buffer.
One issue i found myself annoyed at are numbered files where I want to keep leading zeros (e.g. movie0001.webm
). I can't get vim to format them properly.
The question
I have a vim
buffer containing:
mov70.webm
mov71.webm
mov72.webm
mov73.webm
mov74.webm
mov75.webm
mov76.webm
mov77.webm
mov78.webm
mov79.webm
And my cursor starts at the m
in the first line. I then do VG
to mark everything and 69<C-x>
to transform it into:
mov1.webm
mov2.webm
mov3.webm
mov4.webm
mov5.webm
mov6.webm
mov7.webm
mov8.webm
mov9.webm
mov10.webm
But i would really like to reach this instead:
mov01.webm
mov02.webm
mov03.webm
mov04.webm
mov05.webm
mov06.webm
mov07.webm
mov08.webm
mov09.webm
mov10.webm
What i have tried
The problem with numbers with leading zeros is that vim
will treat them as octal
, therefore I changed nrformats
to an empty string:
:set nrformats=
Yet, that did not help. I have searched around in :h nrformats
without finding anything useful.
:subsitute
+printf
– muru Jun 24 '16 at 22:21