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

Re: changing cwd (easy)

Expand Messages
  • Hiroshi Iwatani
    If I understand your requirement correctly, while yu re editing test.txt, do ... -- Hiroshi Iwatani *stop cruelty* Annual number of institutionally euthanized
    Message 1 of 5 , Nov 1, 2003
    • 0 Attachment
      If I understand your requirement correctly,

      while yu're editing test.txt, do

      :sav test2.txt

      jonah wrote:
      > Hi,
      >
      > How can you set the current working directory to the directory of the current
      > file?
      >
      > Also, is there a way to do a "Save as" and start working on the new file in one
      > simple command?
      > That is, say your working on test.txt. I want a shortcut for doing this:
      >
      > :w test2.txt
      > :e test2.txt
      >
      > Thanks for any info,
      > jonah
      >
      >

      --
      Hiroshi Iwatani

      *stop cruelty* Annual number of institutionally euthanized cats and dogs
      including kittens and puppies: US 5 million, JP 500 thousand. How about your
      country? *for our better karma*
      ---------------------
    • Gary Johnson
      ... or ... See ... Gary -- Gary Johnson | Agilent Technologies garyjohn@spk.agilent.com | Wireless Division
      Message 2 of 5 , Nov 1, 2003
      • 0 Attachment
        On 2003-11-01, jonah <jonahgoldstein@...> wrote:
        > Hi,
        >
        > How can you set the current working directory to the directory of the current
        > file?

        :cd %:p:h

        or

        :lcd %:p:h

        See

        :help cd
        :help lcd
        :help filename-modifiers

        Gary

        --
        Gary Johnson | Agilent Technologies
        garyjohn@... | Wireless Division
        | Spokane, Washington, USA
      • Antoine J. Mechelynck
        ... There is, but I m not sure. Maybe :cd %:p:h ? (or :lcd instead of :cd to change dir only for the current window) ... see :help :saveas ... Regards,
        Message 3 of 5 , Nov 1, 2003
        • 0 Attachment
          jonah <jonahgoldstein@...> wrote:
          > Hi,
          >
          > How can you set the current working directory to the directory of the
          > current file?

          There is, but I'm not sure. Maybe ":cd %:p:h"? (or :lcd instead of :cd to
          change dir only for the current window)
          >
          > Also, is there a way to do a "Save as" and start working on the new
          > file in one simple command?
          > That is, say your working on test.txt. I want a shortcut for doing
          > this:
          >
          > > w test2.txt
          > > e test2.txt

          see ":help :saveas"
          >
          > Thanks for any info,
          > jonah

          Regards,
          Tony.
        • Ing. Stanislav Sitar
          ... put this into your .vimrc Change to the directory the file in your current buffer is in autocmd BufEnter * :cd %:p:h I have copied it from somewhere
          Message 4 of 5 , Nov 3, 2003
          • 0 Attachment
            >Hi,
            >
            >How can you set the current working directory to the directory of the current
            >file?
            >
            >Also, is there a way to do a "Save as" and start working on the new file in one
            >simple command?

            put this into your .vimrc

            " Change to the directory the file in your current buffer is in
            autocmd BufEnter * :cd %:p:h

            I have copied it from somewhere quite a long time ago, and I can't
            imagine living without it.

            Enjoy.
            Stano
          Your message has been successfully submitted and would be delivered to recipients shortly.