The content below this paragraph is entirely written by ChatGPT, which solved a problem I had about using vim. In one sense, it is magical that now you can solve this sort of niche tech problem with just a few prompts. On the other hand, it does take away the incentive for people to ask and answer tech questions—to ask for help and to help—on the internet. Many fear LLMs will doom the internet as a place where humans create content. I agree that is a possibility, and I will try to resist it by promising that I will not post anything generated by AI here anymore. (This paragraph is of course revised by an AI. 😁)

Vim one-liner: bump an ISO date by 7 (no strftime)

I wanted a dead-simple way to nudge the day in a YYYY-MM-DD date by 7—no date math functions. Here’s the one-liner I use.

Example

Before:

* [ ] 1x (exercise 15min) (2025-08-22)  #0876fd6e

Command (on the current line):

:s/\v\d{4}-\d{2}-\zs\d{2}/\=printf('%02d', submatch(0)+7)/

After:

* [ ] 1x (exercise 15min) (2025-08-22)  #0876fd6e

To apply to the whole file:

:%s/\v\d{4}-\d{2}-\zs\d{2}/\=printf('%02d', submatch(0)+7)/g

How it works (briefly)

  • \v puts the regex in “very magic” mode.
  • \d{4}-\d{2}-\zs\d{2} matches an ISO date and uses \zs to set the start of the replacement at the day.
  • \= turns the replacement into an expression.
  • submatch(0)+7 adds seven to the matched day; printf('%02d', …) keeps it zero-padded.

Caveat: This is intentionally naive—it won’t handle month/year rollovers (e.g., 2025-01-272025-01-34). If you need real date arithmetic, use strptime/strftime.