Wednesday, September 5, 2012

Re: Diff 2 files with lines added at top of second file: confusing

On 2012-09-05, chroyer wrote:
>
> > My first thought would be some autocmd or a manually-triggered
> > mapping, would ":windo if &diff | 0 | endif" to ensure that all
> > diff windows are at the top.
>
> Thanks for the idea! Based on your suggestion, this is how I
> launch the diff now:
> gvim.exe -d a.txt b.txt +"windo 0"
>
> and things *seemed* to work, until I switch a and b:
> gvim.exe -d b.txt a.txt +"windo 0"
>
> and I run in the same issue...

I thought I had a solution. If I start vim like this,

vim -N -u NONE -d -c 'exe "normal 9999\<C-Y>"' a.txt b.txt

then I get the desired display of the top of b.txt with a.txt and
b.txt in either order. However, I've been unable to find an
autocommand that will do the same thing. I have tried

au BufWinEnter * exe "normal 9999\<C-Y>"

and

au FilterWritePost * exe "normal 9999\<C-Y>"

without success.

":help -c" says,

-c {command} {command} will be executed after the first file
has been read (and after autocommands and
modelines for that file have been processed).
...

so it is apparently important to wait until late in the startup
sequence before scrolling, but I don't know why a "late" autocommand
event such as BufWinEnter or FilterWritePost wouldn't be late
enough.

Maybe this will give someone else an idea.

Regards,
Gary

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