command when file is closed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

command when file is closed

Michael Wagner
Hello folks,

I am on linux Debian and my signature files are handled by fortune. When
I add a new signature with vim, the dat file for the sigfile must also
be updated, to tell fortune the changes. At the moment I have an alias
for this

alias vim-add-sig='vim + ~/sigs/signature + ~/sigs/signature_english && \\
for i in $(find ~/sigs/ -not -name "*.dat" -type f); do strfile $i; done'

I'm sure it's possible to add the for loop in my .vimrc when I edit my
sigfiles, but I don't know how.

tia Michael

--
A mouse may be useful, but only for cat food.

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

signature.asc (923 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: command when file is closed

David Woodfall
On Saturday 4 August 2018 14:28,
Michael Wagner <[hidden email]> put forth the proposition:

> Hello folks,
>
> I am on linux Debian and my signature files are handled by fortune. When
> I add a new signature with vim, the dat file for the sigfile must also
> be updated, to tell fortune the changes. At the moment I have an alias
> for this
>
> alias vim-add-sig='vim + ~/sigs/signature + ~/sigs/signature_english && \\
> for i in $(find ~/sigs/ -not -name "*.dat" -type f); do strfile $i; done'
>
> I'm sure it's possible to add the for loop in my .vimrc when I edit my
> sigfiles, but I don't know how.

:for {var} in {list}
<do stuff>
:endfo[r]

See :help :for

-Dave

--

The chat program is in public domain.  This is not the GNU public license.
If it breaks then you get to keep both pieces.
  -- Copyright notice for the chat program

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

--
--
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: command when file is closed

David Woodfall
On Monday 6 August 2018 11:30,
Dave Woodfall <[hidden email]> put forth the proposition:

> On Saturday 4 August 2018 14:28,
> Michael Wagner <[hidden email]> put forth the proposition:
> > Hello folks,
> >
> > I am on linux Debian and my signature files are handled by fortune. When
> > I add a new signature with vim, the dat file for the sigfile must also
> > be updated, to tell fortune the changes. At the moment I have an alias
> > for this
> >
> > alias vim-add-sig='vim + ~/sigs/signature + ~/sigs/signature_english && \\
> > for i in $(find ~/sigs/ -not -name "*.dat" -type f); do strfile $i; done'
> >
> > I'm sure it's possible to add the for loop in my .vimrc when I edit my
> > sigfiles, but I don't know how.
>
> :for {var} in {list}
> <do stuff>
> :endfo[r]
>
> See :help :for

Sorry, I just copy/pasted that without thinking (too early in the
am), but you don't need to prepend the : in a file.

for
..
endfor

There is also a while loop too, if you need one.

--

On a normal ascii line, the only safe condition to detect is a 'BREAK'
- everything else having been assigned functions by Gnu EMACS.
  -- Tarl Neustaedter

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

--
--
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: command when file is closed

Michael Wagner
On Aug 06, 2018 um 11:47:39, David Woodfall wrote:

> On Monday 6 August 2018 11:30,
> Dave Woodfall <[hidden email]> put forth the proposition:
> > On Saturday 4 August 2018 14:28,
> > Michael Wagner <[hidden email]> put forth the proposition:
> > > Hello folks,
> > >
> > > I am on linux Debian and my signature files are handled by fortune. When
> > > I add a new signature with vim, the dat file for the sigfile must also
> > > be updated, to tell fortune the changes. At the moment I have an alias
> > > for this
> > >
> > > alias vim-add-sig='vim + ~/sigs/signature + ~/sigs/signature_english && \\
> > > for i in $(find ~/sigs/ -not -name "*.dat" -type f); do strfile $i; done'
> > >
> > > I'm sure it's possible to add the for loop in my .vimrc when I edit my
> > > sigfiles, but I don't know how.
> >
> > :for {var} in {list}
> > <do stuff>
> > :endfo[r]
> >
> > See :help :for
>
> Sorry, I just copy/pasted that without thinking (too early in the
> am), but you don't need to prepend the : in a file.
>
> for
> ..
> endfor
>
> There is also a while loop too, if you need one.
Hello David,

thanks for your answer, but it is not for my question. Sorry if it
wasn't clear enough.
I want to know how I start the command 'strfile' when I edit my sigfile.
I have this not functional snippet in my .vimrc

autocmd BufWritePost $HOME/sigs/* exe "!/usr/bin/strfile"

and the errormessage is

:!/usr/bin/strfile
No input file name
strfile [-iorsx] [-c char] sourcefile [datafile]

shell returned 1

So how I get the filename commited to the command?

TIA Michael

--
Money is the root of all evils. Send $20 for more info...

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

signature.asc (923 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: command when file is closed

Christian Brabandt

On Mo, 06 Aug 2018, Michael Wagner wrote:

> On Aug 06, 2018 um 11:47:39, David Woodfall wrote:
> > On Monday 6 August 2018 11:30,
> > Dave Woodfall <[hidden email]> put forth the proposition:
> > > On Saturday 4 August 2018 14:28,
> > > Michael Wagner <[hidden email]> put forth the proposition:
> > > > Hello folks,
> > > >
> > > > I am on linux Debian and my signature files are handled by fortune. When
> > > > I add a new signature with vim, the dat file for the sigfile must also
> > > > be updated, to tell fortune the changes. At the moment I have an alias
> > > > for this
> > > >
> > > > alias vim-add-sig='vim + ~/sigs/signature + ~/sigs/signature_english && \\
> > > > for i in $(find ~/sigs/ -not -name "*.dat" -type f); do strfile $i; done'
> > > >
> > > > I'm sure it's possible to add the for loop in my .vimrc when I edit my
> > > > sigfiles, but I don't know how.
> > >
> > > :for {var} in {list}
> > > <do stuff>
> > > :endfo[r]
> > >
> > > See :help :for
> >
> > Sorry, I just copy/pasted that without thinking (too early in the
> > am), but you don't need to prepend the : in a file.
> >
> > for
> > ..
> > endfor
> >
> > There is also a while loop too, if you need one.
>
> Hello David,
>
> thanks for your answer, but it is not for my question. Sorry if it
> wasn't clear enough.
> I want to know how I start the command 'strfile' when I edit my sigfile.
> I have this not functional snippet in my .vimrc
>
> autocmd BufWritePost $HOME/sigs/* exe "!/usr/bin/strfile"
>
> and the errormessage is
>
> :!/usr/bin/strfile
> No input file name
> strfile [-iorsx] [-c char] sourcefile [datafile]
>
> shell returned 1
>
> So how I get the filename commited to the command?

I guess you want something like:

autocmd BufWritePost $HOME/sigs/* exe ":!/usr/bin/strfile" expand("<amatch>")


Best,
Christian
--
Was hilft aller Sonnenaufgang, wenn wir nicht aufstehen.
                -- Georg Christoph Lichtenberg

--
--
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: command when file is closed

Michael Wagner
On Aug 06, 2018 um 15:47:18, Christian Brabandt wrote:

>
> On Mo, 06 Aug 2018, Michael Wagner wrote:
>
> > thanks for your answer, but it is not for my question. Sorry if it
> > wasn't clear enough.
> > I want to know how I start the command 'strfile' when I edit my sigfile.
> > I have this not functional snippet in my .vimrc
> >
> > autocmd BufWritePost $HOME/sigs/* exe "!/usr/bin/strfile"
> >
> > and the errormessage is
> >
> > :!/usr/bin/strfile
> > No input file name
> > strfile [-iorsx] [-c char] sourcefile [datafile]
> >
> > shell returned 1
> >
> > So how I get the filename commited to the command?
>
> I guess you want something like:
>
> autocmd BufWritePost $HOME/sigs/* exe ":!/usr/bin/strfile" expand("<amatch>")
>
>
Hello Christian,

that's it, thanks for your answer

Michael

--
It's not the principle of the thing, it's the money

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

signature.asc (923 bytes) Download Attachment