Window-local and Tab-local previous directories?

67 views
Skip to first unread message

Yegappan Lakshmanan

unread,
May 7, 2019, 11:10:58 PM5/7/19
to vim_dev
Hi all,

When you change the directory using the :cd or :tcd or :lcd commands,
the previous directory is remembered. You can change to this
directory, by passing "-" as the directory name to these commands.

Currently only a single previous directory is remembered across
:cd, :lcd and :tcd. If you have a tabpage local directory and change
the global directory using ":cd", then the previous directory for
the :tcd is also changed.

I think we should keep a separate previous directory for every window
with a local directory, every tabpage with a local directory and the
global directory. Any comments/suggestions?

- Yegappan

Bram Moolenaar

unread,
May 8, 2019, 4:29:15 PM5/8/19
to vim...@googlegroups.com, Yegappan Lakshmanan
It might complicate things too much. When I use ":lcd somedir" and then
"cd -", what directory gets used for "-"?

--
ARTHUR: If you do not open these doors, we will take this castle by force ...
[A bucket of slops land on ARTHUR. He tries to retain his dignity.]
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yegappan Lakshmanan

unread,
May 9, 2019, 1:52:37 AM5/9/19
to Bram Moolenaar, vim_dev
Hi Bram,

On Wed, May 8, 2019 at 1:29 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Yegappan wrote:
>
> > When you change the directory using the :cd or :tcd or :lcd commands,
> > the previous directory is remembered. You can change to this
> > directory, by passing "-" as the directory name to these commands.
> >
> > Currently only a single previous directory is remembered across
> > :cd, :lcd and :tcd. If you have a tabpage local directory and change
> > the global directory using ":cd", then the previous directory for
> > the :tcd is also changed.
> >
> > I think we should keep a separate previous directory for every window
> > with a local directory, every tabpage with a local directory and the
> > global directory. Any comments/suggestions?
>
> It might complicate things too much. When I use ":lcd somedir" and then
> "cd -", what directory gets used for "-"?
>

With the proposed change, in the above case you will get a "No previous
directory" error message after "cd -". But if you use ":lcd -", then
the directory
will be changed to "somedir".

If you use a separate tabpage for each project directory, then currently when
you change directory in one of the tab pages, the previous directory of all
the tab pages will be changed. With the proposed change the previous
directory of only the current tab page will be changed.

Regards,
Yegappan

Bram Moolenaar

unread,
May 9, 2019, 7:36:12 AM5/9/19
to vim...@googlegroups.com, Yegappan Lakshmanan
I don't like that the meaning of "-" depends on where or how you use it.
I would rather think of using another special name for "previous
window-local directory", "previous tab-local directory" and "previous
global directory". Perhaps -l, -t and -g?

--
Why is "abbreviation" such a long word?

Yegappan Lakshmanan

unread,
May 10, 2019, 4:09:54 PM5/10/19
to Bram Moolenaar, vim_dev
Hi Bram,
The updated help description for the :cd, :tcd and :lcd commands
with the support for the -l, -t and -g arguments is below. Let me know
if you have any comments.

Regards,
Yegappan

*:cd-* *E186*
:cd[!] - Change to the previous current directory (before the
previous ":cd {path}" or the ":tcd {path}" or the
":lcd {path}" command).

*:cd-g* *:cd-t* *:cd-l*
:cd[!] -g
:cd[!] -t
:cd[!] -l Change to the previous global (|:cd|) or tabpage-local
(|:tcd|) or window-local (|:lcd|) current directory
respectively.

*:tcd-*
:tcd[!] - Change to the previous current directory (before the
previous ":cd {path}" or the ":tcd {path}" or the
":lcd {path}" command).

*:tcd-g* *:tcd-t* *:tcd-l*
:tcd[!] -g
:tcd[!] -t
:tcd[!] -l Change to the previous global (|:cd|) or tabpage-local
(|:tcd|) or window-local (|:lcd|) current directory
respectively.

*:lcd-*
:lcd[!] - Change to the previous current directory (before the
previous ":cd {path}" or the ":tcd {path}" or the
":lcd {path}" command).

*:lcd-g* *:lcd-t* *:lcd-l*
:lcd[!] -g
:lcd[!] -t
:lcd[!] -l Change to the previous global (|:cd|) or tabpage-local
(|:tcd|) or window-local (|:lcd|) current directory
respectively.

Bram Moolenaar

unread,
May 10, 2019, 5:20:08 PM5/10/19
to vim...@googlegroups.com, Yegappan Lakshmanan
I think that's the best way we provide this functionality. But I like
to hear from others.

For the help itself, it's repetitive. I would put the info about -, -l,
-t and -g in a section and refer to it from the individual commands.
Something like:

*:cd-g* *:cd-t* *:cd-l* *:cd-* *E186*
:cd[!] -[gtl] Change to a previous current directory.
See |xxx| for the possible arguments.

--
The Characters and incidents portrayed and the names used are fictitious and
any similarity to the names, characters, or history of any person is entirely
accidental and unintentional.
Signed RICHARD M. NIXON
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Yegappan Lakshmanan

unread,
May 11, 2019, 12:34:50 PM5/11/19
to Bram Moolenaar, vim_dev
Hi all,
Any comments/suggestions about the new commands and the
behavior of the commands?

Thanks,
Yegappan

Manuel Ortega

unread,
May 11, 2019, 1:12:46 PM5/11/19
to vim_dev
On Friday, May 10, 2019 at 5:20:08 PM UTC-4, Bram Moolenaar wrote:

> I think that's the best way we provide this functionality. But I like
> to hear from others.

I think this is adding complexity, a maintenance burden, and yet another corner for corner-cases to hide in, all for the sake of a *very* niche use-case. (Has anybody complained about this yet in all the years of :lcd existing?)

This seems to be exactly the sort of thing for which a user should just make some custom ":Lcd" or ":Tcd" that e.g. uses the DirChanged autcommand event to store the value of getcwd() in some w:variable (or t:variable) for possible later use.

-Manny

Yegappan Lakshmanan

unread,
May 14, 2019, 12:17:06 PM5/14/19
to vim_dev, vim...@googlegroups.com
Hi,

On Sat, May 11, 2019 at 10:12 AM Manuel Ortega <manny...@gmail.com> wrote:
>
> On Friday, May 10, 2019 at 5:20:08 PM UTC-4, Bram Moolenaar wrote:
>
> > I think that's the best way we provide this functionality. But I like
> > to hear from others.
>
> I think this is adding complexity, a maintenance burden, and yet another
> corner for corner-cases to hide in, all for the sake of a *very* niche
> use-case. (Has anybody complained about this yet in all the years of :lcd
> existing?)
>

When the ":cd -" or ":tcd -" or ":lcd -" commands are used, a user will
expect to go back to the previous directory. When a tab-local directory
is used, a user will expect that the previous current directory will be
the one before the last :tcd command used for the current tabpage. With
the current implementation, the previous directory will be the current
directory before invoking the last ":cd" or ":tcd" or ":lcd" command.
This may not be the expected directory.

For example, let us say you are using a separate tabpage for each
project. You use the ":tcd" command to switch to the project specific
root directory in each tabpage. Now you change the directory in one of
the tabpages to look at some files inside the corresponding project. Now
the previous directory of all the other tabpages will also be changed.
If you go to some other tabpage and use the ":tcd -" command, the
current directory will be changed to that of the other project and not
the current project. This may not be expected behavior.

Regards,
Yegappan

Manuel Ortega

unread,
May 16, 2019, 9:38:06 PM5/16/19
to vim_dev

This does not address anything in my objection.

-Manny

Reply all
Reply to author
Forward
0 new messages