Hi, Tim Chase wrote: >>> zeros on the left if needed. Ideally, Vim would provide a >>> right() function where you could just do something like >>> >>> right('0'.submatch(1), 2) >>> >>> to zero-pad to 2 places. Alas, the substitute() trick is the >>> easiest way I've found to simulate this. >> repeat('0', 2 - strlen(submatch(1))) . submatch(1) > > A slight step in the right direction. Two caveats, however: > > 1) if strlen(submatch(1)) > 2 (in other cases, not this > particular one where it's limited to at most 2 characters > initially), then this formula can end up with a result that is > > 2 characters. A true right() function would never return more > than 2 characters (okay...insert funky tangent about > unicode/UTF-8 characters here).
function! Right(s, n) return strpart(s, strlen(s) - n, n) endfunction Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)