On Thursday 20 July 2006 11:10, [EMAIL PROTECTED] wrote:
> What is the easiest way to edit a file that is in the same directory as
> the current file? E.g. I open a file like this: vim /x/y/z/w/file1.c and
> want to now open /x/y/z/w/file2.c? Occasionally want to open files in
> the parent directory of current file's directory. It would be nice if
> there is a special character like "," which starts from the current
> buffer's directory. So ":e ,/file2.c" would work. Or maybe "~~" double
> tilda character if "," doesn't work...
A while back I defined the mapping
cmap , <c-r>=expand('%:h')<cr>/
which kind of does what you suggested - it inserts the path to the current file
when you type a comma in the command line. I've found it very useful.
For what I'm doing at present, it suits me to have it. But it does mean that
when I want a real comma (eg in a search pattern, or a :set command) I have to
use Ctrl-v or Ctrl-q first.
I guess it could easily be improved call a function which checks the command
line to see if it starts with
:e, :sp, and whatever else is appropriate - and otherwise inserts a regular
comma. I'll let you know if I get around to it.
John