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

lcd and split view

Expand Messages
  • Paul J
    ... Hash: SHA1 Dear All, I read the documentation for lcd: *:lc* *:lcd* ... current window. The current directory for other windows is not changed. {not in
    Message 1 of 2 , Feb 1, 2003
    • 0 Attachment
      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Dear All,

      I read the documentation for lcd:

      *:lc* *:lcd*
      :lc[d] {path} Like |:cd|, but only set the current directory for the
      current window. The current directory for other
      windows is not changed. {not in Vi}

      Now I got the impression that 'window' meant buffer. Have I got this
      wrong?

      I work in sp[lit] view most of the time. I call the different parts of
      the split windows. Is this wrong? In any case, I would like to have a
      per split working directory. Hence the following .vimrc addition would
      set the top split to its local dir and similarly for the bottom split:

      function! Change_Current_Dir()
      let _dir = expand("%:p:h")
      exec "lcd " . _dir
      unlet _dir
      endfunction

      autocmd BufEnter * call Change_Current_Dir()

      The keen readers amongst you will notice this is a vim tip. It is a
      brilliant one but would work even better if I understood what a window
      was!

      Thanks,


      Paul
      - --
      Department of Computing, Imperial College London
      http://myitcv.org.uk/
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.0.6 (GNU/Linux)
      Comment: For info see http://www.gnupg.org

      iD8DBQE+PBTe0YkfvYj92P4RArMHAJ9IARE94vnEHKoYcQNKqNvnBP4LygCfVtLl
      mt3DQFAueMICC/FZc+co3BE=
      =kZJH
      -----END PGP SIGNATURE-----
    • Antoine J. Mechelynck
      ... [...] A window in vim can be two different things: 1. (rarely used) the program window is the whole screen and/or off-screen area covered by gvim, as
      Message 2 of 2 , Feb 2, 2003
      • 0 Attachment
        Paul J <paul@...> wrote:
        > -----BEGIN PGP SIGNED MESSAGE-----
        > Hash: SHA1
        >
        > Dear All,
        >
        > I read the documentation for lcd:
        >
        > *:lc* *:lcd*
        > > lc[d] {path} Like |:cd|, but only set the current directory for the
        > current window. The current directory for other
        > windows is not changed. {not in Vi}
        >
        > Now I got the impression that 'window' meant buffer. Have I got this
        > wrong?
        >
        > I work in sp[lit] view most of the time. I call the different parts of
        > the split windows. Is this wrong? In any case, I would like to have a
        > per split working directory. Hence the following .vimrc addition would
        > set the top split to its local dir and similarly for the bottom split:
        >
        > function! Change_Current_Dir()
        > let _dir = expand("%:p:h")
        > exec "lcd " . _dir
        > unlet _dir
        > endfunction
        >
        > autocmd BufEnter * call Change_Current_Dir()
        >
        > The keen readers amongst you will notice this is a vim tip. It is a
        > brilliant one but would work even better if I understood what a window
        > was!
        >
        > Thanks,
        >
        >
        > Paul
        > - --
        > Department of Computing, Imperial College London
        > http://myitcv.org.uk/
        > -----BEGIN PGP SIGNATURE-----
        [...]

        A "window" in vim can be two different things:
        1. (rarely used) the "program window" is the whole screen and/or
        off-screen area covered by gvim, as defined by :winpos, :set lines and :set
        columns
        2. (usually) the part of a file visible onscreen; every :split or
        :vsplit creates a new "window" in that sense

        A "buffer" is, roughly speaking, a file in memory. A buffer can be displayed
        in a "window" (sense 2), but it can also be "hidden" or even "unlisted". To
        see all listed and unlisted buffers (there may be quite a lot of them), do
        :ls!

        See also :help windows.txt

        If you use :lcd to set the current dir on a per-window basis, it will be
        remembered if you go to another window and come back (for instance with
        Ctrl-W w followed by Ctrl-W W), so IMHO setting it again in an autocommand
        for BufEnter is overkill. BufRead or BufWinEnter should be enough IIUC.

        HTH,
        Tony.
      Your message has been successfully submitted and would be delivered to recipients shortly.