mag37 revised this gist 3 hours ago. Go to revision
1 file changed, 31 insertions
VIM_tricks.md(file created)
| @@ -0,0 +1,31 @@ | |||
| 1 | + | ## Convert EPOCH timestamp to datetime within VIM | |
| 2 | + | ||
| 3 | + | Select all lines then: (remember the dot within `[0-9.]` if decimal-epoch) | |
| 4 | + | `:'<,'>s/\([0-9.]\+\)/\=strftime('%c', submatch(1))` | |
| 5 | + | ||
| 6 | + | Result: | |
| 7 | + | ``` | |
| 8 | + | # From: | |
| 9 | + | 1779764414.0, test, ABC123, X | |
| 10 | + | # To: | |
| 11 | + | Tue 26 May 2026 05:00:14 AM CEST, test, ABC123, X | |
| 12 | + | ``` | |
| 13 | + | ---- | |
| 14 | + | ||
| 15 | + | ## Add/Change to numbers incrementally on each line | |
| 16 | + | Lets say you've got this: | |
| 17 | + | ``` | |
| 18 | + | Line A oneoneone | |
| 19 | + | Line B twotwotwo | |
| 20 | + | Line C threethreethree | |
| 21 | + | ``` | |
| 22 | + | Put a 0 (or any starting number) where you want the incremental number to be. | |
| 23 | + | Eg. at beginning of line with `:s/^/0/g` or the *A B C* in the above example with ctrl+v selection. | |
| 24 | + | ||
| 25 | + | Then select all `ggVG` and `g<C-A>` to incrementally increase all the numbers. | |
| 26 | + | Result: | |
| 27 | + | ``` | |
| 28 | + | Line 1 oneoneone | |
| 29 | + | Line 2 twotwotwo | |
| 30 | + | Line 3 threethreethree | |
| 31 | + | ``` | |
Newer
Older