2015-05-31 17:57 GMT+03:00 Peng Yu <pengyu.ut@gmail.com>:
> 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 <Bram@vim.org>
> "/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 vim_use+unsubscribe@googlegroups.com.
> 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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment