Last active 4 hours ago

Revision 8fd2dff5288c67d1914c16495edf4e67ec68e128

VIM_tricks.md Raw

Convert EPOCH timestamp to datetime within VIM

Select all lines then: (remember the dot within [0-9.] if decimal-epoch)
:'<,'>s/\([0-9.]\+\)/\=strftime('%c', submatch(1))

Result:

# From:
1779764414.0, test, ABC123, X
# To:
Tue 26 May 2026 05:00:14 AM CEST, test, ABC123, X

Add/Change to numbers incrementally on each line

Lets say you've got this:

Line A oneoneone
Line B twotwotwo
Line C threethreethree

Put a 0 (or any starting number) where you want the incremental number to be.
Eg. at beginning of line with :s/^/0/g or the A B C in the above example with ctrl+v selection.

Then select all ggVG and g<C-A> to incrementally increase all the numbers.
Result:

Line 1 oneoneone
Line 2 twotwotwo
Line 3 threethreethree