Say I'm editing file foo
. I want to copy/write what I have in the buffer to bar
and change the buffer to be editing bar
instead of foo
. I can achieve this with:
:w bar
:e bar
But that has a few problems
- If
bar
is actually/usr/local/share/long/path/to/bar
, I really don't want to type that in twice, even with tab completion. - It reloads the file, potentially messing with the settings/folds/etc. I had for that buffer.
- The working directory is left the same.
1 is the biggest problem I'd like a solution to address; 2 would be really helpful, 3 is more of a "nice to have."
Is there a cleaner way to do this?
:cd %:p:h
.:we
-- is that what you're looking for?