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

Re: open a file with a different path than specified

Expand Messages
  • Samuel Ferencik
    Hi, cool, it works! I guess I never considered the BufReadPost option because I did not want to read (the same) file twice, but it does what I need. I will
    Message 1 of 6 , Feb 25, 2009
    • 0 Attachment
      Hi,

      cool, it works! I guess I never considered the BufReadPost option
      because I did not want to read (the same) file twice, but it does what
      I need. I will stick with it.

      By the way, to perform all the autocmds during the re-opening, I had
      to make this a nested autocmd. And, to avoid recursion, I am using a
      window variable (w:reOpening):

      autocmd BufReadPost *:*.* nested if exists("w:reOpening") &&
      w:reOpening |
      \ let w:reOpening = 0 |
      \ else |
      \ let w:reOpening = 1 |
      \ execute "e " . substitute(system("write sys$output f
      $search(\"" . expand("<afile>") . "\")"), ";\\d*", "", "") |
      \ endif

      Is there a smarter way to redo all the autocmds upon re-opening the
      file? I can't just :doau everything, because I would redo this
      autocommand too...

      Thanks alot, Nazri.

      Sam

      On Feb 25, 12:41 pm, Nazri Ramliy <ayieh...@...> wrote:
      > On Wed, Feb 25, 2009 at 7:33 PM, Samuel Ferencik <sferen...@...> wrote:
      > > I will have to search on, I guess.
      >
      > In your original email you used BufReadPre autocommand.
      >
      > Try it with BufReadPost.  It tried it here on my linux in my .vimrc:
      >
      >     au BufReadPost test.txt e /tmp/test.txt
      >
      > And it seems to work (editing existing test.txt in any folder opens
      > the file /tmp.txt).
      >
      > You can modify that to call your system command to get the wanted effect.
      >
      > nazri.
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.