Thursday, December 10, 2020

Re: Vim-script question

On 2020-12-10, 'Klaus Jantzen' via vim_use wrote:
> Hi,
>
> I want to include in my .vimrc an autocommand that writes some new
> lines into an empty file e.g. an zsh script.
>
> So I wrote
>
> au  BufNewFile *.zsh :a "#! /usr/bin/zsh"
>
> but that does not do what I want (it does not do anything).
>
> So my question: How can I write with the autocommand one or more
> lines into an empty buffer?
>
> Thanks for your help.

The :a command does not take an argument, it starts inserting lines
that are typed after :a is executed. The following should do what
you want.

au BufNewFile *.zsh a
au BufNewFile *.zsh #!/usr/bin/zsh

Another command you could use is :put, e.g.,

au BufNewFile *.zsh 0put ='#!/usr/bin/zsh'

Regards,
Gary

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201210174220.GA15174%40phoenix.

No comments:

Post a Comment