On Sat 21-Oct-06 6:59am -0600, Bram Moolenaar wrote:

> This happens when the edited file already is in the buffer list.
> I'll fix it by using "tabedit" instead of "tabnew | edit".

Ah, thanks for explaining that.  I knew that making that
replacement solved the problem but didn't know why.

I had used a shell script to fix the problem.  Since I don't
know how to do a multi-line replace is SED, I used console
Vim as a super SED!  The one-liner is simply:

vim -u NONE -i NONE -Nnes "+%%s/tabnew\nedit/tabedit/|wq" %1

where '%1' is the placeholder for the sessionfile and '%%s'
is needed in 4nt because '%s' would be thought of as an
environment variable.  This was an interesting and
productive exercise, because it taught me how to use console
Vim as a very powerful "batch" tool (I had never used the
'-es' combo before).

This afternoon, I wrote a ':command' to do this within Gvim
(or Vim) for my _vimrc:

com! -narg=1 MS mks! <args>
    \|sil sp <args>
    \|sil %s/tabnew\nedit/tabedit/
    \|sil w
    \|bw
    \|redr!
    \|echohl Warning
    \|echomsg "Session saved using tabedit"
    \|echohl NONE

This works fine.

One last question is how can I get my restored session to
have buffer numbers 1 - n instead of 2 - n+1 (which is the
way mksession does things)?

-- 
Best regards,
Bill

Reply via email to