What is the difference between using multiple -c options and concatenating the options with newline as the separator? (autocmd)

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

What is the difference between using multiple -c options and concatenating the options with newline as the separator? (autocmd)

Peng Yu
The following vim command lines show different results. Could anybody
help me understand why there is a difference? Thanks.

$ vim -T dumb -c autocmd\ BufWrite\ \*\ echom\ \"Writing\ buffer\!\"
-c w -c messages -c q
/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD

"/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD" 0L, 0C
"/private/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD"
0L, 0C written
Messages maintainer: Bram Moolenaar <[hidden email]>
"/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD" 0L, 0C
Writing buffer!
"/private/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD"
0L, 0C written
$ vim -T dumb -c $'autocmd BufWrite * echom "Writing
buffer!"\nw\nmessages' -c q
/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD

"/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD" 0L, 0C

--
Regards,
Peng

--
--
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: What is the difference between using multiple -c options and concatenating the options with newline as the separator? (autocmd)

Nikolay Aleksandrovich Pavlov
2015-05-31 17:57 GMT+03:00 Peng Yu <[hidden email]>:

> The following vim command lines show different results. Could anybody
> help me understand why there is a difference? Thanks.
>
> $ vim -T dumb -c autocmd\ BufWrite\ \*\ echom\ \"Writing\ buffer\!\"
> -c w -c messages -c q
> /var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD
>
> "/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD" 0L, 0C
> "/private/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD"
> 0L, 0C written
> Messages maintainer: Bram Moolenaar <[hidden email]>
> "/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD" 0L, 0C
> Writing buffer!
> "/private/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD"
> 0L, 0C written
> $ vim -T dumb -c $'autocmd BufWrite * echom "Writing
> buffer!"\nw\nmessages' -c q
> /var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD
>
> "/var/folders/r7/bvmh1vvx41d63snvgbdz7bl40000gr/T/tmp.ZICAEj0GJD" 0L, 0C

-c context is same as in `:execute`. I do not know whether you can
find this in help, but

1. When reading from file \n is “string end”. `\` at the start of the
next line joins current line with the next, but it is handled by some
kind of preprocessor. Except for some rare cases Ex commands end also
when string ends.
2. When using :execute \n is “command separator”. Follows nearly the
same rules as `|` regarding separating commands. Since `:autocmd`
cannot be separated from another command using bar first variant is
like `autocmd BufWrite * echomsg "Writing buffer!" | write |
messages`: `write` and `messages` commands are part of the autocmd.

>
> --
> Regards,
> Peng
>
> --
> --
> 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.