1

例如:如何让时间戳都减1,谢谢:)

srt 文本文件的一部分:

1
00:00:04,110 --> 00:00:08,409 
hi my name's mike

......

我想让它成为:

1
00:00:03,110 --> 00:00:07,409 
hi my name's mike

......
4

2 回答 2

3

speeddating.vim 插件 ( https://github.com/tpope/vim-speeddating ) 允许您使用 vim 的 CTRL-A/CTRL-X 递增/递减键来处理多种格式的日期和时间。

只需安装它,然后转到 srt 文件中的秒列并按 CTRL-X。Speeddating 理解 23:23:00 变为 23:22:59 和 23:00:00 变为 22:59:59。

然后,您可以使用“g 命令”“自动”更改,例如:

:g/\v^\d{2}:\d{2}:/execute "normal t,10\<C-x>2t,10\<C-x>"

将序列的开始和结束时间缩短 10 秒。

t 和 2t 将您带到该行中的第一个和第二个逗号,将您置于秒列。2t: 和 3t: 会让你进入分钟等等,或者使用你喜欢的任何运动命令(可能是 7l 17l 秒)。

于 2014-06-10T19:15:51.137 回答
1

你可以使用 vim 的正则表达式来得到你想要的:

:%s;\(\d\{2}\)\(,\d\{3}\);\=printf("%02d%s", submatch(1) - 1, submatch(2));g

:           - begin command line mode.
%           - entire file.
s           - substitute.
;           - field separator.
\(          - begin sub-expression.
\d          - match digit.
\{2)        - match exactly two.
\)          - end sub-expression.
,           - actual comma.
\{3)        - match exactly three.
printf()    - internal vim function (see :h printf).
submatch(1) - match first sub-expression.
submatch(2) - match second sub-expression.
g           - replace all occurrences in the line.
于 2013-09-29T15:35:15.043 回答