:wn to :x like map/abbrev ?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

:wn to :x like map/abbrev ?

M Kelly
Hi,

When editting many files I can just do :wn to save and go to next, but
just curious, does anyone know of a mapping/abbrev so that :x acts like
:x for one file (and the last file), but acts like :wn for the files in
between ?  Or really just saves curent and loads next w/o a prompt ?

thx always for vim,
-m

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: :wn to :x like map/abbrev ?

John Passaro
Maybe you can define a function:

function NextOrQuit()
    write
    if argidx() + 1 == argc()
        exit  # same as :x
    else
        wnext
    endif
endfunction

then invoke it from a mapping or command of your choice, say :X or \x or ,x

Not so flexible with the exclamation marks and ++options that :[w]next / :[w]quit / :x seem to all support, but it may be good enough for simple cases

John Passaro
(917) 678-8293


On Thu, Dec 6, 2018 at 4:02 PM M Kelly <[hidden email]> wrote:
Hi,

When editting many files I can just do :wn to save and go to next, but
just curious, does anyone know of a mapping/abbrev so that :x acts like
:x for one file (and the last file), but acts like :wn for the files in
between ?  Or really just saves curent and loads next w/o a prompt ?

thx always for vim,
-m

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: :wn to :x like map/abbrev ?

Tony Mechelynck
In reply to this post by M Kelly
On Thu, Dec 6, 2018 at 10:02 PM M Kelly <[hidden email]> wrote:

>
> Hi,
>
> When editting many files I can just do :wn to save and go to next, but
> just curious, does anyone know of a mapping/abbrev so that :x acts like
> :x for one file (and the last file), but acts like :wn for the files in
> between ?  Or really just saves curent and loads next w/o a prompt ?
>
> thx always for vim,
> -m

:x (exit) saves your file if modified, then closes its window. If it
is the last non-help window, Vim exits. This is the general cases:
there are special cases, for instance if the current buffer is
unnamed, which cause an error. IOW, in the normal case, :x reduces the
number of windows by one (saving the editfile if necessary)

OTOH, :wn writes the current files then starts editing the next file
in the arguments list in the same window. It doesn't change the number
of open windows.

Making the one act like the other would confuse me.

Best regards,
Tony.

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: :wn to :x like map/abbrev ?

M Kelly
Hi,

Thanks.  I will look into that func, or something like it.

> Making the one act like the other would confuse me.

I think I'm really only asking for a :x to save and move on with out prompting.

take care
-m

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: :wn to :x like map/abbrev ?

Bram Moolenaar

> Thanks.  I will look into that func, or something like it.
>
> > Making the one act like the other would confuse me.
>
> I think I'm really only asking for a :x to save and move on with out prompting.

Something like:
        :update|next
perhaps?

--
"Beware of bugs in the above code; I have only proved
it correct, not tried it." -- Donald Knuth

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: :wn to :x like map/abbrev ?

M Kelly
Hi,

> Something like:
> :update|next
> perhaps?

ok, cool.  I didn't know about :update.
(I could even maybe handle E163, E165 for the last one)

take care,
and thank you and everyone for vim,
-m

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: :wn to :x like map/abbrev ?

Andy Wokula
Am 08.12.2018 um 14:16 schrieb M Kelly:

> Hi,
>
>> Something like:
>> :update|next
>> perhaps?
>
> ok, cool.  I didn't know about :update.
> (I could even maybe handle E163, E165 for the last one)
>
> take care,
> and thank you and everyone for vim,
> -m

and check out
    :h 'autowrite

--
Andy

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.