Nnn: alignment of nodes listed in Batch rename

Created on 19 Apr 2020  路  6Comments  路  Source: jarun/nnn

When I hit r in a folder, in this example a folder of music tracks, with the recently added feature of file-numbering on the left, there is a visual step at file number 10:

1 ./01 The Monitor
2 ./03 Click, Click, Click, Click
3 ./04 The Chinatown Bus
4 ./05 Flight 180
5 ./06 Like Castanets
6 ./07 Butterfly Nets
7 ./08 Shrinking Violet
8 ./09 Corazon
9 ./10 Middle Management
10 ./11 Choose Again
11 ./12 The News From Your Bed

This staggering means that I can't visually select an entire column in Vim (here to add a hypen between track number and title) in one go, but have to do the same operation twice (once for files 1-9, then again for the rest).

While in this case, as I'm using vim, and there's a consistency in the start of the file names, I can equally :%s#\(\d\d\) #\1 - # to insert my desired hyphen, but, for more general use-cases, it'd be sweet if you could pad out the first 9 file numbers.

enhancement

All 6 comments

@KlzXS I think this is a nice improvement. Probably the padding needs to be done based on the number of files taken as input. Can you take a look?

Added the padding in a PR. After editing the padding can freely be removed or added further as the script ignores leading and trailing whitespace on a line.

as the script ignores leading and trailing whitespace on a line

What if the filename has a leading or trailing whitespace OR the user wants to add?

What if the filename has a leading or trailing whitespace OR the user wants to add?

As my old professor used to say: that's a sad story. Unless you want to use some other delimiter which I don't think we should.

Maybe if we used something else instead of read but is it really worth it? How names their files with leading and trailing whitespace?

How names their files with leading and trailing whitespace?

I think we don't need to over-engineer either if someone wants to use crypic names for their files. Just add a note in the plugin that space is the delimiter and should not be used as a suffix or prefix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akimdi picture akimdi  路  5Comments

kuntau picture kuntau  路  3Comments

tim77 picture tim77  路  9Comments

lenormf picture lenormf  路  6Comments

alexx-oo picture alexx-oo  路  3Comments