On 7/31/06, mwoehlke <[EMAIL PROTECTED]> wrote:
> Rodolfo Borges wrote:
>> I made a file with vim commands, starting with
>> #!/usr/bin/vim -S
>> so I can execute the file directly, instead of using "vim -S file".
>> The problem is that vim tries to execute this first line too.
>> Can we have a workaround on this?
>> Like, ignoring "#!" at the start of a command, instead of giving the
>> "no ! allowed" error?
>> Or am I having it all wrong?
> Method I:
> -----8<----- foo (or whatever)
> vim -S foo.vim
> then put the rest in foo.vim and do "chmod a+x foo" or "chmod 0755 foo".
> Method II: add to one of your shell startup scripts (~/.bashrc or
> alias foo='vim -S ~/foo.vim'
> In a vim script, the first line has no special meaning. Empty lines,
> blank lines (i.e. consisting only of spaces and/or tabs) and lines
> starting with zero or more spaces or tabs plus a double quote are
> comments; the rest are ex-commands (which don't have to start with a
> colon). ":#" is synonymous with ":number" so Vim tries to execute your
> first line as the command ":number!/usr/bin/vim -S". Now the ":number"
> command doesn't accept a bang (there is no ":number!" command), so you
> get an error.
So... if it's an error, and we know it's an error, and will always be an
error (at least at the present)... is in unreasonable to make '#!.*', as
the first line of a '-S' script, be ignored?
*I* thought it was a reasonable suggestion...
I think it's reasonable, taking into account that
#! is illegal comand-come command (:# does not take !).