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

RE: Retrieving file path for current buffer

Expand Messages
  • Steven Dodd
    Does anyone know how to retrieve the full path of the file associated with a particular buffer? I know one can use bufname(...), but one has to then do some
    Message 1 of 6 , Jun 24, 2003
    • 0 Attachment
      Does anyone know how to retrieve the full path of the file associated
      with a particular buffer? I know one can use bufname(...), but one has
      to then do some work to complete the path for the filename.

      ?

      ______________________________
      Steven Dodd
      Software Developer, Harmony MR

      905.672.2100x1217
      sdodd@...

      Cedara Software Corp.
      www.cedara.com
    • Tim Chase
      ... is something like ... what you re looking for? ... will give you other things you can use such as ... will give you the path for buffer #4 in the buffer
      Message 2 of 6 , Jun 24, 2003
      • 0 Attachment
        > Does anyone know how to retrieve the full path of the file associated
        > with a particular buffer? I know one can use bufname(...), but one has
        > to then do some work to complete the path for the filename.

        is something like

        :echo expand("%:p:h")

        what you're looking for?

        :he expand

        will give you other things you can use such as

        :echo expand("#4:p:h")

        will give you the path for buffer #4 in the buffer list.

        What are you trying to do with it? It could make it easier to know what
        sort of thing to offer :)

        -tim
      • Antoine J. Mechelynck
        ... or maybe even ... see also ... HTH, Tony
        Message 3 of 6 , Jun 24, 2003
        • 0 Attachment
          Steven Dodd <Steven.Dodd@...> wrote:
          > Does anyone know how to retrieve the full path of the file associated
          > with a particular buffer? I know one can use bufname(...), but one
          > has to then do some work to complete the path for the filename.
          >
          > ?
          >
          > ______________________________
          > Steven Dodd
          > Software Developer, Harmony MR
          >
          > 905.672.2100x1217
          > sdodd@...
          >
          > Cedara Software Corp.
          > www.cedara.com

          :buffer nnn
          :echo expand("%:p")

          or maybe even
          :echo expand(bufname(nnn) . ":p")

          see also
          :help filename-modifiers

          HTH,
          Tony
        • Steven Dodd
          expand( %:p ) seems to it. Thanks guys ... From: Tim Chase [mailto:gumnos@hotmail.com] Sent: Tuesday, June 24, 2003 10:39 AM To: Steven Dodd; vim@vim.org
          Message 4 of 6 , Jun 24, 2003
          • 0 Attachment
            expand("%:p") seems to it. Thanks guys

            -----Original Message-----
            From: Tim Chase [mailto:gumnos@...]
            Sent: Tuesday, June 24, 2003 10:39 AM
            To: Steven Dodd; vim@...
            Subject: Re: Retrieving file path for current buffer


            > Does anyone know how to retrieve the full path of the file associated
            > with a particular buffer? I know one can use bufname(...), but one
            > has to then do some work to complete the path for the filename.

            is something like

            :echo expand("%:p:h")

            what you're looking for?

            :he expand

            will give you other things you can use such as

            :echo expand("#4:p:h")

            will give you the path for buffer #4 in the buffer list.

            What are you trying to do with it? It could make it easier to know what
            sort of thing to offer :)

            -tim
          • David Fishburn
            Piet Delport suggested using the following (which I find very useful): I have this in my _vimrc: cnoreabbrev CD %:p:h Then if I want to reference the path of
            Message 5 of 6 , Jun 25, 2003
            • 0 Attachment
              Piet Delport suggested using the following (which I find very useful):

              I have this in my _vimrc:
              cnoreabbrev CD %:p:h

              Then if I want to reference the path of the current file I am editing I
              use CD.
              When I want to change the vim directory to the directory of the file I
              am in I use:
              :cd CD

              Dave

              -----Original Message-----
              From: Steven Dodd [mailto:Steven.Dodd@...]
              Sent: Tuesday, June 24, 2003 10:26 AM
              To: vim@...
              Subject: RE: Retrieving file path for current buffer


              Does anyone know how to retrieve the full path of the file associated
              with a particular buffer? I know one can use bufname(...), but one has
              to then do some work to complete the path for the filename.

              ?

              ______________________________
              Steven Dodd
              Software Developer, Harmony MR

              905.672.2100x1217
              sdodd@...

              Cedara Software Corp.
              www.cedara.com
            • Piet Delport
              ... It expands CD directly to the current buffer s path, instead of the literal string #:p:h . HTH, -- Piet Delport Today s subliminal thought is:
              Message 6 of 6 , Jul 2, 2003
              • 0 Attachment
                On Wed, 25 Jun 2003 at 09:21:32 -0400, David Fishburn wrote:
                >
                > Piet Delport suggested using the following (which I find very useful):
                >
                > I have this in my _vimrc:
                > cnoreabbrev CD %:p:h
                >
                > Then if I want to reference the path of the current file I am editing I
                > use CD.
                > When I want to change the vim directory to the directory of the file I
                > am in I use:
                > :cd CD

                You might like this version better, which is what i'm using ATM:

                :cnoreabbrev CD <C-R>=expand('%:p:h')<CR>

                It expands "CD" directly to the current buffer's path, instead of the
                literal string "#:p:h".

                HTH,

                --
                Piet Delport
                Today's subliminal thought is:
              Your message has been successfully submitted and would be delivered to recipients shortly.