[vim/vim] `:lcd` and `:tcd` affect future new windows and tabpages (Issue #9509)

16 views
Skip to first unread message

Evgeni Chasnovski

unread,
Jan 11, 2022, 10:21:21 AM1/11/22
to vim/vim, Subscribed

Steps to reproduce

For :lcd:

  1. vim --clean
  2. :lcd .
  3. :botright new
  4. :verbose pwd

For :tcd:

  1. vim --clean
  2. :tcd .
  3. :tabnew
  4. :verbose pwd

Expected behaviour

In both cases I expected to have [global] current directory to be active instead of [window] and [tabpage]. My reasoning:

  • Documentation states that change will be applied to current window and tab respectively. Sources: for lcd, for tcd.
  • A more detailed description of their behavior has the following statements:
    • "When jumping to another [window|tab page], the current directory is changed to the last specified local [current directory|for that tab page]".
    • "Windows where the :lcd command has not been used stick to the global or tab-local current directory."
    • "The current directory of other tab pages is not affected."

My understanding is that when creating a new window or tabpage it conforms to all the statements:

  • No local current directory was specified.
  • Local command (:lcd or :tcd) has not been used.
  • It is other instance.

So, as always, this is indeed an intended behavior and documentation should be updated, or is not intended and subject for a fix.

Version of Vim

8.2.4051

Environment

OS: Ubuntu 20.04
Terminal: Kitty 0.23.1
Value of $TERM: xterm-kitty
Shell: zsh 5.8

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9509@github.com>

Yegappan Lakshmanan

unread,
Jan 11, 2022, 10:32:44 AM1/11/22
to vim_dev, reply+ACY5DGCABLVVBHSUPZ...@reply.github.com, vim/vim, Subscribed
Hi,

On Tue, Jan 11, 2022 at 7:21 AM Evgeni Chasnovski <vim-dev...@256bit.org> wrote:

Steps to reproduce

For :lcd:

  1. vim --clean
  2. :lcd .
  3. :botright new
  4. :verbose pwd

For :tcd:

  1. vim --clean
  2. :tcd .
  3. :tabnew
  4. :verbose pwd

Expected behaviour

In both cases I expected to have [global] current directory to be active instead of [window] and [tabpage]. My reasoning:


When you open a window/tabpage, the new window/tabpage inherits the current directory of the previous 
window/tabpage. So if the previous window was using a window-local directory, then the new window will
also use the same window-local directory.

Regards,
Yegappan

vim-dev ML

unread,
Jan 11, 2022, 10:33:05 AM1/11/22
to vim/vim, vim-dev ML, Your activity

Hi,

On Tue, Jan 11, 2022 at 7:21 AM Evgeni Chasnovski ***@***.***>
wrote:


> Steps to reproduce
>
> For :lcd:
>
> 1. vim --clean
> 2. :lcd .
> 3. :botright new
> 4. :verbose pwd
>
> For :tcd:
>
> 1. vim --clean
> 2. :tcd .
> 3. :tabnew
> 4. :verbose pwd

>
> Expected behaviour
>
> In both cases I expected to have [global] current directory to be active
> instead of [window] and [tabpage]. My reasoning:
>

When you open a window/tabpage, the new window/tabpage inherits the current
directory of the previous
window/tabpage. So if the previous window was using a window-local
directory, then the new window will
also use the same window-local directory.

Regards,
Yegappan


>
> - Documentation states that change will be applied to *current* window

> and tab respectively. Sources: for lcd
> <https://github.com/vim/vim/blob/0bbca540f7377889e2154aa5731f6eeffcb5c0cc/runtime/doc/editing.txt#L1351-L1354>,
> for tcd
> <https://github.com/vim/vim/blob/0bbca540f7377889e2154aa5731f6eeffcb5c0cc/runtime/doc/editing.txt#L1337-L1341>
> .
> - A more detailed description
> <https://github.com/vim/vim/blob/0bbca540f7377889e2154aa5731f6eeffcb5c0cc/runtime/doc/editing.txt#L1386-L1398>

> of their behavior has the following statements:
> - "When jumping to another [window|tab page], the current directory

> is changed to the last specified local [current directory|for that tab
> page]".
> - "Windows where the :lcd command has not been used stick to the

> global or tab-local current directory."
> - "The current directory of other tab pages is not affected."
>
> My understanding is that when creating a *new* window or tabpage it

> conforms to all the statements:
>
> - No local current directory was specified.
> - Local command (:lcd or :tcd) has not been used.
> - It is *other* instance.

>
> So, as always, this is indeed an intended behavior and documentation
> should be updated, or is not intended and subject for a fix.
> Version of Vim
>
> 8.2.4051
> Environment
>
> OS: Ubuntu 20.04
> Terminal: Kitty 0.23.1
> Value of $TERM: xterm-kitty
> Shell: zsh 5.8
> Logs and stack traces
>
> *No response*
>
>
>


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9509/1010080056@github.com>

Bram Moolenaar

unread,
Jan 11, 2022, 10:34:41 AM1/11/22
to vim/vim, vim-dev ML, Comment

The help for :new mentions:
"This behaves like a ":split" first, and then an ":enew" command."
Isn't that enough explanation?


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you commented.Message ID: <vim/vim/issues/9509/1010081525@github.com>

Bram Moolenaar

unread,
Jan 11, 2022, 10:34:42 AM1/11/22
to vim/vim, vim-dev ML, Comment

Closed #9509.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you commented.Message ID: <vim/vim/issue/9509/issue_event/5874329635@github.com>

Evgeni Chasnovski

unread,
Jan 11, 2022, 10:49:39 AM1/11/22
to vim/vim, vim-dev ML, Comment

Thank you both for your answers.

When you open a window/tabpage, the new window/tabpage inherits the current directory of the previous window/tabpage.

I understand that this is what is happening, but can't find information whether it is intentional.

The help for :new mentions: "This behaves like a ":split" first, and then an ":enew" command." Isn't that enough explanation?

Well, for me this is both not the best place and not clear enough. Something more explicit somewhere around documentation of :lcd and :tcd would be better.
I have only now found the 22.2 The current directory section where it is clearly stated that it is an intended behavior, but it was not that easy to find.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you commented.Message ID: <vim/vim/issues/9509/1010095442@github.com>

Reply all
Reply to author
Forward
0 new messages