DEV Community

Discussion on: Find, convert and replace dates with Vim substitutions

Collapse
 
moopet profile image
Ben Sinclair

This is really cool.

Worth pointing out that relying on external commands is not portable (in this case it's specific to BSD date) and that you could also pipe the system command through | tr -d "\n" to get rid of any trailing newlines.

Collapse
 
jkreeftmeijer profile image
Jeff Kreeftmeijer

Hey Ben, 👋

Thanks for your kind words!

There’s some more about the differences between BSD and GNU date in the original. You’re right, though; using external dependencies makes this less portable.

I used the nested substitution to show another crazy thing you can do within a substitution. Piping the result from the date command through tr is probably easier to remember, so I'll add a quick note about that. Thanks!