Quantcast

Moving a file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Moving a file

shawn wilson
How do I change which file a buffer is pointing to so that I can do a simple :w and get notified if an external app updates it, etc? 

--
--
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
|  
Report Content as Inappropriate

Re: Moving a file

Michael Henry-5
On 12/10/2016 04:07 PM, shawn wilson wrote:
> How do I change which file a buffer is pointing to so that I
> can do a simple :w and get notified if an external app updates
> it, etc?

If I'm understanding your question, you're looking for ``:saveas
newfilename``.  This will both save the file and associate
newfilename with the buffer; from this point on, it will behave
the same as if you'd started Vim with ``vim newfilename``.

Michael Henry

--
--
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
|  
Report Content as Inappropriate

Re: Moving a file

Nikolay Aleksandrovich Pavlov
2016-12-11 15:53 GMT+03:00 Michael Henry <[hidden email]>:
> On 12/10/2016 04:07 PM, shawn wilson wrote:
>> How do I change which file a buffer is pointing to so that I
>> can do a simple :w and get notified if an external app updates
>> it, etc?
>
> If I'm understanding your question, you're looking for ``:saveas
> newfilename``.  This will both save the file and associate
> newfilename with the buffer; from this point on, it will behave
> the same as if you'd started Vim with ``vim newfilename``.

No, not at all. It will create a *new* buffer associated with the new
file name and save the file. Old buffer is also preserved with the old
file name. Help is incorrect on the matter. Associating current buffer
with the different name is done with :file command, though it will not
write to a file (need explicit :write or something like this).

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

--
--
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
|  
Report Content as Inappropriate

Re: Moving a file

Nikolay Aleksandrovich Pavlov
2016-12-11 16:45 GMT+03:00 Nikolay Aleksandrovich Pavlov <[hidden email]>:

> 2016-12-11 15:53 GMT+03:00 Michael Henry <[hidden email]>:
>> On 12/10/2016 04:07 PM, shawn wilson wrote:
>>> How do I change which file a buffer is pointing to so that I
>>> can do a simple :w and get notified if an external app updates
>>> it, etc?
>>
>> If I'm understanding your question, you're looking for ``:saveas
>> newfilename``.  This will both save the file and associate
>> newfilename with the buffer; from this point on, it will behave
>> the same as if you'd started Vim with ``vim newfilename``.
>
> No, not at all. It will create a *new* buffer associated with the new
> file name and save the file. Old buffer is also preserved with the old
> file name. Help is incorrect on the matter. Associating current buffer
> with the different name is done with :file command, though it will not
> write to a file (need explicit :write or something like this).

Though no, :saveas is something more weird: it *does* rename a buffer
unlike what I said earlier, but it also creates a new buffer with
*old* name.

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

--
--
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
|  
Report Content as Inappropriate

Re: Moving a file

Bryan Richter
On Sun, Dec 11, 2016 at 06:17:59PM +0300, Nikolay Aleksandrovich Pavlov wrote:

> 2016-12-11 16:45 GMT+03:00 Nikolay Aleksandrovich Pavlov <[hidden email]>:
> > 2016-12-11 15:53 GMT+03:00 Michael Henry <[hidden email]>:
> >> On 12/10/2016 04:07 PM, shawn wilson wrote:
> >>> How do I change which file a buffer is pointing to so that I
> >>> can do a simple :w and get notified if an external app updates
> >>> it, etc?
> >>
> >> If I'm understanding your question, you're looking for ``:saveas
> >> newfilename``.  This will both save the file and associate
> >> newfilename with the buffer; from this point on, it will behave
> >> the same as if you'd started Vim with ``vim newfilename``.
> >
> > No, not at all. It will create a *new* buffer associated with the new
> > file name and save the file. Old buffer is also preserved with the old
> > file name. Help is incorrect on the matter. Associating current buffer
> > with the different name is done with :file command, though it will not
> > write to a file (need explicit :write or something like this).
>
> Though no, :saveas is something more weird: it *does* rename a buffer
> unlike what I said earlier, but it also creates a new buffer with
> *old* name.
It does seem to me that :saveas or :file will possibly answer the
original question, but... what *is* the original question?

Shawn, what is it you're trying to do, exactly? The two parts of your
question ("changing which file a buffer points to" and "get notified
when a file is externally modified") are unrelated in vim.

--
--
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 (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Moving a file

arocker

> Shawn, what is it you're trying to do, exactly? The two parts of your
> question ("changing which file a buffer points to" and "get notified
> when a file is externally modified") are unrelated in vim.
>

This is a vim-related list, but this does raise the question of whether
vim is even the appropriate tool? It sounds like some some sort of
monitoring effort.

Vim is wonderful for a human creating or updating a text, then going away
to do something else. Operations involving multiple files, intermittent or
unpredictable events, and other situations fit other programs better.

The programs in the *nix tool chest are all powerful and flexible. As a
result, sufficiently dedicated perversity can bend almost all of them to
do jobs wildly different from their designers' intentions. (Video games
written in sed, for example:https://github.com/aureliojargas/sokoban.sed
.) Just because it's possible doesn't make it advisable.

--
--
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
|  
Report Content as Inappropriate

Re: Moving a file

John Passaro
Vim normally offers a pretty lightweight bit of change detection and I think Shawn was only asking how to apply that to a new filename. In that context, ":saveas" seems to work:

    $ vim a
    :saveas b
    :! echo hello >> b
    W11: Warning: File "b" has changed since editing started


On Sun, Dec 11, 2016 at 12:42 PM, <[hidden email]> wrote:

> Shawn, what is it you're trying to do, exactly? The two parts of your
> question ("changing which file a buffer points to" and "get notified
> when a file is externally modified") are unrelated in vim.
>

This is a vim-related list, but this does raise the question of whether
vim is even the appropriate tool? It sounds like some some sort of
monitoring effort.

Vim is wonderful for a human creating or updating a text, then going away
to do something else. Operations involving multiple files, intermittent or
unpredictable events, and other situations fit other programs better.

The programs in the *nix tool chest are all powerful and flexible. As a
result, sufficiently dedicated perversity can bend almost all of them to
do jobs wildly different from their designers' intentions. (Video games
written in sed, for example:https://github.com/aureliojargas/sokoban.sed
.) Just because it's possible doesn't make it advisable.

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

--
--
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
|  
Report Content as Inappropriate

Re: Moving a file

shawn wilson
Sorry for the late reply (to my own thread).

On Sun, Dec 11, 2016 at 1:36 PM, John Passaro <[hidden email]> wrote:
> Vim normally offers a pretty lightweight bit of change detection and I think
> Shawn was only asking how to apply that to a new filename. In that context,
> ":saveas" seems to work:
>
>     $ vim a
>     :saveas b
>     :! echo hello >> b
>     W11: Warning: File "b" has changed since editing started
>

Yes, this is exactly what I meant, and yeah :saveas was what I was
looking for - thank y'all and sorry for the confusion.

> John Passaro
> (917) 678-8293
> http://riemann-summary.blogspot.com
> http://www.soundcloud.com/a-straight-john-at-last
>
> On Sun, Dec 11, 2016 at 12:42 PM, <[hidden email]> wrote:
>>
>>
>> > Shawn, what is it you're trying to do, exactly? The two parts of your
>> > question ("changing which file a buffer points to" and "get notified
>> > when a file is externally modified") are unrelated in vim.
>> >
>>
>> This is a vim-related list, but this does raise the question of whether
>> vim is even the appropriate tool? It sounds like some some sort of
>> monitoring effort.
>>
>> Vim is wonderful for a human creating or updating a text, then going away
>> to do something else. Operations involving multiple files, intermittent or
>> unpredictable events, and other situations fit other programs better.
>>
>> The programs in the *nix tool chest are all powerful and flexible. As a
>> result, sufficiently dedicated perversity can bend almost all of them to
>> do jobs wildly different from their designers' intentions. (Video games
>> written in sed, for example:https://github.com/aureliojargas/sokoban.sed
>> .) Just because it's possible doesn't make it advisable.
>>
>> --
>> --
>> 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.
>
>
> --
> --
> 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.

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