Hi!

I have a log file with timestamps and messages:

01:00 x
02:00 y
03:00 z

To compare the time elapsed between two events I want to prefix each line with the timestamp of the previous time. I tried to use

%s/^/\=matchstr(getline(line(".")-1), "\\d\\{2}:\\d\\{2} ")

but somehow the first match is prepended to every line:

01:00 x
01:00 02:00 y
01:00 03:00 z

A larger example would be the file

http://www.rfc-editor.org/in-notes/rfc-index.txt

with the command

%s/^/\=matchstr(getline(line(".")-1), "\\d\\{4} ")

The first match 1129 from line 24 is prepended to every following line.


Where is the problem?


Thanks in advance,
Dennis Benzinger

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to