Quantcast

Refresh/reload an opened file

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

Refresh/reload an opened file

Carlo Trimarchi

Hi,
is there any way to reload or refresh a file I'm currently working on?

When I work on files on a server, it happens that I keep different of
them opened in tabs. While I work on a file, a friend of mine is
working on another (that I have opened there) and if he makes some
changes, to see them I have to close and reopen the file. I'd like to
just refresh it (as long as I didn't changed it, of course). Is there
anything like this?

Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Gary Johnson-4

On 2009-05-07, Mr.SpOOn wrote:
> Hi,
> is there any way to reload or refresh a file I'm currently working on?
>
> When I work on files on a server, it happens that I keep different of
> them opened in tabs. While I work on a file, a friend of mine is
> working on another (that I have opened there) and if he makes some
> changes, to see them I have to close and reopen the file. I'd like to
> just refresh it (as long as I didn't changed it, of course). Is there
> anything like this?

    :e

Regards,
Gary



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Tim Chase
In reply to this post by Carlo Trimarchi

> is there any way to reload or refresh a file I'm currently working on?

Just use

   :e

to reload the file.  I believe, if you've made changes to the
file, it requires you to do

   :e!

to force-discard your local changes and reload from the disk.

If I'm not sure, I'll often yank my current copy into a scratch
buffer/window, force-reload the file from disk, and then use

   :diffthis

on each of the two buffers/windows to verify that there are no
surprises.

You may also be interested in the 'autoread' setting.

More information at

   :help FileChangedShell
   :help 'autoread'
   :help :e
   :help :diffthis

-tim




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Anton-3

2009/5/7 Tim Chase <[hidden email]>:
...
> If I'm not sure, I'll often yank my current copy into a scratch
> buffer/window, force-reload the file from disk, and then use
>
>   :diffthis
>
> on each of the two buffers/windows to verify that there are no
> surprises.

I have found, that the most comfortable way to do this is
DiffOrig command, described in the VIM help (you should define it
self though). One this command does the something very similar to
all those copy/paste/force reload/diffthis stuff.

:help DiffOrig

--
Anton

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Tony Mechelynck
In reply to this post by Carlo Trimarchi

On 07/05/09 01:17, Mr.SpOOn wrote:

>
> Hi,
> is there any way to reload or refresh a file I'm currently working on?
>
> When I work on files on a server, it happens that I keep different of
> them opened in tabs. While I work on a file, a friend of mine is
> working on another (that I have opened there) and if he makes some
> changes, to see them I have to close and reopen the file. I'd like to
> just refresh it (as long as I didn't changed it, of course). Is there
> anything like this?
>
> Thanks.

- To reload unconditionally, from wherever it is, the file you're
curretly editing:
        :e " read-write if the file has read-write permissions
or
        :view " always readonly

- To check whether any of the file(s) you're currently editing has been
changed by someone else:
        :checkt[ime]

If a file or its datestamp have changed, then if 'autoread' is set and
the file is not 'modified' in your instance of Vim, Vim will reload it
without prompting. Otherwise, Vim will ask you what you want to do about
the change.

See
        :help :edit
        :help :checktime
        :help 'autoread'


Best regards,
Tony.
--
The Briggs/Chase Law of Program Development:
        To determine how long it will take to write and debug a
program, take your best estimate, multiply that by two, add one, and
convert to the next higher units.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Tony Mechelynck
In reply to this post by Anton-3

On 10/05/09 08:14, Anton Sharonov wrote:

>
> 2009/5/7 Tim Chase<[hidden email]>:
> ...
>> If I'm not sure, I'll often yank my current copy into a scratch
>> buffer/window, force-reload the file from disk, and then use
>>
>>    :diffthis
>>
>> on each of the two buffers/windows to verify that there are no
>> surprises.
>
> I have found, that the most comfortable way to do this is
> DiffOrig command, described in the VIM help (you should define it
> self though). One this command does the something very similar to
> all those copy/paste/force reload/diffthis stuff.
>
> :help DiffOrig
>

If, like mine, your vimrc sources the vimrc_example.vim, then you
already have it.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
31. You code your homework in HTML and give your instructor the URL.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Carlo Trimarchi
In reply to this post by Gary Johnson-4

2009/5/7 Gary Johnson <[hidden email]>:
>
>    :e

Thanks, it was really simple, but I didn't think about that and I
couldn't find anything searching for "refresh" or "reload".

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Refresh/reload an opened file

Chris Mueller-3
In reply to this post by Tony Mechelynck


On Sun, May 10, 2009 at 4:28 AM, Tony Mechelynck <[hidden email]> wrote:

On 10/05/09 08:14, Anton Sharonov wrote:
>
> 2009/5/7 Tim Chase<[hidden email]>:
> ...
>> If I'm not sure, I'll often yank my current copy into a scratch
>> buffer/window, force-reload the file from disk, and then use
>>
>>    :diffthis
>>
>> on each of the two buffers/windows to verify that there are no
>> surprises.
>
> I have found, that the most comfortable way to do this is
> DiffOrig command, described in the VIM help (you should define it
> self though). One this command does the something very similar to
> all those copy/paste/force reload/diffthis stuff.
>
> :help DiffOrig
>

If, like mine, your vimrc sources the vimrc_example.vim, then you
already have it.


Best regards,
Tony.
Random; but I liked this command; so wrote a little wrapper to toggle it... (broken if you change buffers I know, but my scripting is horrible at best for vim)

function! DiffOrig()
    if &diff
        wincmd p | bdel | diffoff
    else
        vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
    endif
endfunction
map <leader>do :call DiffOrig()<cr>


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Loading...