Tuesday, May 30, 2017

Re: Insert lines at begin of file with writefile

Le mardi 30 mai 2017 13:03:38 UTC+2, ZyX a écrit :
> 2017-05-30 11:21 GMT+03:00 Ni Va <nivaemail@gmail.com>:
> > Hi,
> >
> >
> > Is that a way to tell writefile() func to append lines at the beginning of file?
>
> Just read the whole file, prepend and then write the whole file. In
> any case I do not know a way to actually prepend bytes to the file: if
> you seek to the end of file (or open it in append mode) and start
> writing to it you get appending. If you seek to the start and start
> writing you will just overwrite first bytes. So programming languages
> do not have "prepending" abstraction because it is not supported by
> the OS and thus is going to either cost very much or have problems
> like loosing data on crashes.
>
> >
> > Thank you
> > Niva
> >
> > --
> > --
> > 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.

Do you think readfile writefile would be faster than that :

let begin = [$vimruntime."/gvim.exe", "-c", "edit ".makefile, "-c",
\"call append(0, ".string(lines2Append).")", "-c", "wq"]
call x.add_cmd(begin) " ==>>>> Launch cmd as job

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

No comments:

Post a Comment