Friday, November 26, 2010

Re: Switching between 2 files

On 11/24/2010 02:17 PM, epanda wrote:
> Tab1: file1.txt
>
> 2010_11_01__23:30:32.333 footext
> 2010_11_01__23:30:35.633 footext
> 2010_11_01__23:30:37.633 footext
>
> Tab2: file2.txt
>
> 2010_11_01__23:30:32.333 bartext
> 2010_11_01__23:30:35.633 bartext
> 2010_11_01__23:30:37.633 bartext
>
> I would like by left mouse clicking on date_time field to switch
> between file1 to file2.
>
> Is it possible ?

My first thought is "yes, it's likely possible" (my strategy
sans-code at the bottom), but it would help to understand what
you're trying to do (the bigger picture). It sounds almost as if
you're attempting to diff the two files, jumping back and forth
between them to compare.

A simple mashup would involve using the standard *nix tool "join"
to join the two files into one based on the timestamp field:

join file1.txt file2.txt | vim -

to show the merged version.

Alternatively, I'd consider putting each timestamp on its own
line in both files and then diffing the results:

vim file1.txt file2.txt
:vert all
:windo %s/ /\r/
:windo diffthis

Both of those would allow for me to see everything in one place
instead of jumping back and forth between tabs.

To answer your question, I'd likely map <leftmouse> to yank the
time-stamp from the beginning of the clicked-line, jump to the
alternate tab, and then search for that resulting timestamp at
the beginning of the line.

-tim


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

No comments: