Loading ...
Sorry, an error occurred while loading the content.

How to refresh (reload) an opened file?

Expand Messages
  • Andy Richer
    Hi vim Guru: I opened a report file that is changed once I correct some code and re-generate report. Is there a way that I can do refresh or reload without
    Message 1 of 13 , Feb 26, 2013
    • 0 Attachment
      Hi vim Guru:

      I opened a report file that is changed once I correct some code and re-generate report.
      Is there a way that I can do "refresh" or "reload" without quit the re-open the file to see updated contents?


      Thanks in advance
      Andy Richer

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       
    • Kfir Shay
      use ... to reload the file. if you ve made changes to the file ... -- -- You received this message from the vim_use maillist. Do not top-post! Type your
      Message 2 of 13 , Feb 26, 2013
      • 0 Attachment
        use 
        :e 

        to reload the file.  if you've made changes to the file
        :e! 


        On Tue, Feb 26, 2013 at 1:53 PM, Andy Richer <andy.richer@...> wrote:
        Hi vim Guru:

        I opened a report file that is changed once I correct some code and re-generate report.
        Is there a way that I can do "refresh" or "reload" without quit the re-open the file to see updated contents?


        Thanks in advance
        Andy Richer

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
         
         
      • Tim Chase
        ... Depends on what behavior you want, and whether you want to preserve any changes you made in the first version of the output. To re-read the file from
        Message 3 of 13 , Feb 26, 2013
        • 0 Attachment
          On 2013-02-26 10:53, Andy Richer wrote:
          > I opened a report file that is changed once I correct some code and
          > re-generate report.
          > Is there a way that I can do "refresh" or "reload" without quit the
          > re-open the file to see updated contents?

          Depends on what behavior you want, and whether you want to preserve
          any changes you made in the first version of the output. To re-read
          the file from disk, you can use

          :e

          (note: no filename) If you've made changes in the current buffer,
          you can abandon those with

          :e!

          If you want to keep the current version in Vim and read the existing
          file into another buffer, you can do that either by preserving what
          you have into another scratch buffer and re-reading as above:

          :%y " yank the old contents
          :new " create a new buffer
          :put " dump the old contents into this buffer
          :1d " delete the initial blank line
          :e! " reread the updated file

          Or, you can leave the current buffer pointed at the file and read the
          new file into a new buffer:

          :new " create a new empty buffer
          :r filename.txt " read in the contents from disk
          :1d " delete the initial blank line

          If you want to compare the old-version with the new version, I
          recommend the "yank, new, put, e!" version, possibly followed by a
          ":diffthis" in each buffer.

          -tim



          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • John Little
          ... The autoread option does this. This works well in gvim because there is an implicit ... when gvim regains the input focus. See :help timestamp. If you
          Message 4 of 13 , Feb 26, 2013
          • 0 Attachment
            On Wednesday, February 27, 2013 7:53:00 AM UTC+13, andy richer wrote:

            > Is there a way that I can do "refresh" or "reload" without quit the re-open the file to see updated contents?

            The 'autoread' option does this. This works well in gvim because there is an implicit
            :checktime
            when gvim regains the input focus. See :help timestamp.

            If you want a vim in a terminal to refresh, or gvim without getting the input focus, one can use the client-server stuff to tell vim to check if the file has changed. See :help client-server.

            Regards, John Little

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Sven Guckes
            ... where the # is the alternate file name (read: the file name associated with the alternate buffer). you can probably map this to a key... map
            Message 5 of 13 , Feb 26, 2013
            • 0 Attachment
              * Tim Chase <vim@...> [2013-02-26 20:36]:
              > Or, you can leave the current buffer pointed at
              > the file and read the new file into a new buffer:
              > :new " create a new empty buffer
              > :r filename.txt " read in the contents from disk
              > :1d " delete the initial blank line

              slight variation:

              :new " create a new empty buffer
              :r # " read in the contents from disk
              :1d " delete the initial blank line

              where the '#' is the "alternate file name" (read:
              the file name associated with the alternate buffer).

              you can probably map this to a key...

              map <f9> :new|:r #|:1d

              but when i enter this mapping then the '#' is
              expanded right away and gives me an error:

              E484: Can't open file #

              how to stop that from happening again?

              Sven

              --
              --
              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@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Ben Fritz
              ... In mappings you must either escape the | or use . map :new |:r # |:1d map :new :r # :1d Otherwise, Vim sees this as: map :new
              Message 6 of 13 , Feb 26, 2013
              • 0 Attachment
                On Tuesday, February 26, 2013 1:49:20 PM UTC-6, Sven Guckes wrote:
                >
                > you can probably map this to a key...
                >
                >
                >
                > map <f9> :new|:r #|:1d
                >
                >
                >
                > but when i enter this mapping then the '#' is
                >
                > expanded right away and gives me an error:
                >
                >
                >
                > E484: Can't open file #
                >
                >
                >
                > how to stop that from happening again?
                >


                In mappings you must either escape the | or use <Bar>.

                map <f9> :new\|:r #\|:1d
                map <f9> :new<Bar>:r #<Bar>:1d

                Otherwise, Vim sees this as:

                map <F9> :new

                Followed by a separate :r # command.

                Actually, this is best written without the redundant : characters, and you will need to end command-line mode with <CR>:

                map <f9> :new\|r #\|1d<CR>

                --
                --
                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@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Ben Fritz
                ... Note, this will destroy undo history, unless you have undofile set, and undoreload is a number larger than the number of lines in your file. If
                Message 7 of 13 , Feb 26, 2013
                • 0 Attachment
                  On Tuesday, February 26, 2013 1:10:32 PM UTC-6, Tim Chase wrote:
                  > On 2013-02-26 10:53, Andy Richer wrote:
                  >
                  > > I opened a report file that is changed once I correct some code and
                  >
                  > > re-generate report.
                  >
                  > > Is there a way that I can do "refresh" or "reload" without quit the
                  >
                  > > re-open the file to see updated contents?
                  >
                  >
                  >
                  > Depends on what behavior you want, and whether you want to preserve
                  >
                  > any changes you made in the first version of the output. To re-read
                  >
                  > the file from disk, you can use
                  >
                  >
                  >
                  > :e
                  >
                  >
                  >
                  > (note: no filename) If you've made changes in the current buffer,
                  >
                  > you can abandon those with
                  >
                  >
                  >
                  > :e!
                  >
                  >
                  >

                  Note, this will destroy undo history, unless you have 'undofile' set, and 'undoreload' is a number larger than the number of lines in your file.

                  If 'undofile' and 'undoreload' are set properly, you can actually undo reading in the file if it abandoned your unsaved changes.

                  --
                  --
                  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@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • Gary Johnson
                  ... An easy way to compare the current buffer contents with the version on-disk is to use the DiffOrig command. See ... Regards, Gary -- -- You received this
                  Message 8 of 13 , Feb 26, 2013
                  • 0 Attachment
                    On 2013-02-26, Tim Chase wrote:
                    > On 2013-02-26 10:53, Andy Richer wrote:
                    > > I opened a report file that is changed once I correct some code and
                    > > re-generate report.
                    > > Is there a way that I can do "refresh" or "reload" without quit the
                    > > re-open the file to see updated contents?
                    >
                    > Depends on what behavior you want, and whether you want to preserve
                    > any changes you made in the first version of the output. To re-read
                    > the file from disk, you can use
                    >
                    > :e
                    >
                    > (note: no filename) If you've made changes in the current buffer,
                    > you can abandon those with
                    >
                    > :e!
                    >
                    > If you want to keep the current version in Vim and read the existing
                    > file into another buffer, ...

                    An easy way to compare the current buffer contents with the version
                    on-disk is to use the DiffOrig command. See

                    :help DiffOrig

                    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@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  • taco
                    ... -- -- 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,
                    Message 9 of 13 , May 17, 2013
                    • 0 Attachment
                      :e
                      On Tue, Feb 26, 2013 at 10:53:00AM -0800, Andy Richer wrote:
                      > Hi vim Guru:
                      > I opened a report file that is changed once I correct some code and
                      > re-generate report.
                      > Is there a way that I can do "refresh" or "reload" without quit the
                      > re-open the file to see updated contents?
                      > Thanks in advance
                      > Andy Richer
                      >
                      > --
                      > --
                      > 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 [1]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@....
                      > For more options, visit [2]https://groups.google.com/groups/opt_out.
                      >
                      > References
                      >
                      > 1. http://www.vim.org/maillist.php
                      > 2. https://groups.google.com/groups/opt_out

                      --
                      --
                      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@....
                      For more options, visit https://groups.google.com/groups/opt_out.
                    • Sam Roberts
                      ... e is edit % is current file name -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are
                      Message 10 of 13 , May 18, 2013
                      • 0 Attachment
                        :e %

                        e is edit
                        % is current file name

                        --
                        --
                        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@....
                        For more options, visit https://groups.google.com/groups/opt_out.
                      • Tim Chase
                        ... The % is optional, as that s the default if you don t specify anything. If you ve made unsaved changes to your current buffer, ... Note that reloading
                        Message 11 of 13 , May 18, 2013
                        • 0 Attachment
                          On 2013-05-18 08:42, Sam Roberts wrote:
                          > :e %
                          >
                          > e is edit
                          > % is current file name

                          The "%" is optional, as that's the default if you don't specify
                          anything. If you've made unsaved changes to your current buffer,
                          you'll need to "!" it:

                          :e!

                          Note that reloading loses things like the jump-list and undo history
                          for the buffer, so it might be better to do something like

                          :%d
                          :$r %
                          :0d

                          which should keep at least preserve the undo history though the
                          reload.

                          -tim



                          --
                          --
                          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@....
                          For more options, visit https://groups.google.com/groups/opt_out.
                        • Ben Fritz
                          ... As I mentioned back in February, if you have undofile and undoreload set properly, you can actually undo reading in the file if it abandoned your
                          Message 12 of 13 , May 19, 2013
                          • 0 Attachment
                            On Saturday, May 18, 2013 4:20:48 PM UTC-5, Tim Chase wrote:
                            >
                            > Note that reloading loses things like the jump-list and undo history
                            >
                            > for the buffer, so it might be better to do something like
                            >
                            >
                            >
                            > :%d
                            >
                            > :$r %
                            >
                            > :0d
                            >
                            >
                            >
                            > which should keep at least preserve the undo history though the
                            >
                            > reload.
                            >
                            >
                            >
                            > -tim

                            As I mentioned back in February, if you have 'undofile' and 'undoreload' set properly, you can actually undo reading in the file if it abandoned your unsaved changes.

                            --
                            --
                            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@....
                            For more options, visit https://groups.google.com/groups/opt_out.
                          • Tim Chase
                            ... Ah, I knew this thread sounded familiar, and I d forgotten about that. I m not sure why the thread was resurrected 3 months later o_O -tim -- -- You
                            Message 13 of 13 , May 19, 2013
                            • 0 Attachment
                              On 2013-05-19 18:20, Ben Fritz wrote:
                              > On Saturday, May 18, 2013 4:20:48 PM UTC-5, Tim Chase wrote:
                              >> Note that reloading loses things like the jump-list and undo
                              >> history
                              >
                              > As I mentioned back in February, if you have 'undofile' and
                              > 'undoreload' set properly, you can actually undo reading in the
                              > file if it abandoned your unsaved changes.

                              Ah, I knew this thread sounded familiar, and I'd forgotten about
                              that. I'm not sure why the thread was resurrected 3 months later o_O

                              -tim


                              --
                              --
                              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@....
                              For more options, visit https://groups.google.com/groups/opt_out.
                            Your message has been successfully submitted and would be delivered to recipients shortly.