Change :Rename to use the file's current directory by default #5

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

Soares commented Oct 12, 2012

Let's say you're in project/ and you're editing src/feature/blue.c. You make a bunch of changes and decide that it really should be named red.c now, so you :Rename red.c.

Now you've got project/red.c in your root project directory and nothing in src/feature.

This patch makes :Rename use the directory of the original file if no path fragment is specified.

You can still get the original behavior by doing e.g. :Rename ./red.c in the above example.

Owner
tpope commented Oct 12, 2012

Why not just :Rename %:h/red.c? It's a few more characters, but way less surprising.

Soares commented Oct 12, 2012

I recently turned off autochdir in favor of a file finder plugin and found the current behavior quite surprising.

If I don't specify a filepath I'm intuitively thinking in terms of "rename X to Y", not in terms of "where is this file", so I expect the changes to happen in place.

I can see the mindset from which this change would be counter-intuitive, though, and I don't really have a strong opinion either way. It just seems more intuitive to me.

I'd agree with @Soares. The behavior in the PR is similar to Rename2 plugin, which most users coming to Eunich will be used to using. The current behavior would be very surprising to users of Rename2.

Owner
tpope commented Dec 12, 2012

Heh, I guess the switch in Janus must have caught a lot of people off guard. I made the primary interface :Move, so :Rename could take on new semantics. May as well make it always relative to the current file's directory, no?

Main implication of this is we need to role our own tab complete.

Alternatively, we could drop :Rename entirely.

Soares commented Dec 12, 2012

Another alternative: Make :Move and :Rename have different semantics (one cwd-relative, one file-relative). Disclaimer: this might be a bad idea.

It hasn't really been bugging me now that I know it's cwd-relative, but it was surprising the first few times I used it.

I like that option, :Move having different behavior than :Rename makes sense. As long as it is clearly documented.

Owner
tpope commented Dec 12, 2012

Yeah that's what I meant.

@tpope tpope closed this in 4abf1f5 Dec 31, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment