On Fri, Mar 18, 2011 at 8:59 PM, Michael(Xi Zhang)
<[email protected]>wrote:

> On Fri, Mar 18, 2011 at 8:49 PM, Rostyslaw Lewyckyj 
> <[email protected]>wrote:
>
>> Malte Forkel wrote:
>>
>>> Am 18.03.2011 18:13, schrieb Ben Fritz:
>>>
>>>
>>>> Probably not a built-in way, unless they are similar enough to diff.
>>>>
>>>> Actually you may be able to play with Vim's diffexpr to allow this to
>>>> work, but you probably won't be able to rely on the normal external
>>>> diff tool unless the logs are very similar.
>>>>
>>>>
>>>>
>>> Unfortenately, the logs are very different.
>>>
>>> Would it be possible to write a script that is triggered by scrolling
>>> one windows and then scrolls the connected (bound) windows? Given the
>>> amount scrolled (in terms of number of lines) and the time interval now
>>> shown (timestamps of first and last line shown), the script should be
>>> able to determine the new top (or bottom, depending on scroll direction)
>>> line in all connected windows, based on the timestamps in those files
>>> and compute the necessary scroll offset (in terms auf number lines) for
>>> those windows.
>>>
>>> Are the hooks and the information required to do this availabe in/from
>>> vim?
>>>
>>>
>>>
>> How is time indicated in each of the two (log) files?
>> Is each of the lines time stamped i.e. labeled   e.g.
>>  yyyy:mm:dd:hh:mm:ss.ssss?
>> If so then after scrolling log1, place the new start line at the top of
>> the window,
>> extract its' time stamp, move to log2, search for the time stamp, move the
>> line (in log2) to the top of its window.
>> If the number of lines in a given interval is different in the two logs
>> then,
>> of course, that will show up in the displays
>>
>>
> I think maybe you can use a script to do this:
> for example, get the time of the first line of the current window, and
> search this time on the other window, and let the first result display at
> the first line of the window.
>
> I don't know how to write this script, I hope someone else can do it.
>

You can try the following script, just put it into your vimrc file,
This method requires you open 2 splited windows and have the 2 files you
want to compare.
In the left window press ALT-l, it will call ZX_log function, search the
time in another window.

I'm not sure the time format in your file, I use format like this
: 2010-10-11 3:00:00 , so the length is 18, you can change the length of the
strpart function if you need.
"z<cr>  -- set the current line to the top
"wincmd l  -- move cursor to right window
"wincmd h -- move cursor back to left window

nmap <M-l> :call <SID>ZX_log()<cr> \| z<cr>
function s:ZX_log()
    let timestr = strpart(getline(line('.')),0,18)
    :wincmd l
    execute 'vimgrep ' '/'.timestr.'/' ' %'
    :wincmd h

endfunction

The function is very simple and maybe need to be refined.

-- 
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