you could modify it to the following to return to the normal command mode
(although cmdwin mode is quite nice, imo, once you're accustomed to it):

:cmap %/ ^R%^F$F/lDyy:q^M:^R"

this does a deletion ("D") to the end of the line, yanks the contents of the
line, exits the cmdwin, re-enters normal command mode, and puts the contents
of the default register.

there are 2 new digraphs here that weren't used above:

^[  (equivalent to the escape key)  =  <C-k>EC
^M (equivalent to the return key)  =  <C-k>CR

I haven't tested the above change, but i'm pretty sure it (or something
almost identical) will work.
Let me know if this helps!

On Sun, Nov 16, 2008 at 12:33 PM, madiyaan <[EMAIL PROTECTED]> wrote:

>
>
>
> On Nov 16, 12:26 pm, madiyaan <[EMAIL PROTECTED]> wrote:
> > On Nov 14, 5:16 pm, "Chris Suter" <[EMAIL PROTECTED]> wrote:
> >
> > > you could do a mapping such as the following:
> >
> > > :cmap %/ ^R%^FF/lC
> >
> > Thank you. This would be something very useful. However, it doesn't
> > work in my current vim. When I put in just this:
> >
> > > :cmap %/ ^R%
> >
> > It does place the entire full path of the current file in there. But
> > if I put in the full command that you wrote here, it instead shows me
> > a history of commands (basically the same window when I do q:) instead
> > of leaving me with the path of the current file. Any ideas what could
> > be going wrong? I entered the digraphs correctly as it shows me those
> > in a different color when I wrote them to my .vimrc file.
> >
> > Also, I tried entering F/lC while in normal mode in front of a path in
> > a regular buffer, and it worked. It seems to me that ^F is not doing
> > what it should be doing (i.e. it is not putting me into normal mode on
> > the Ex line). Any help would be appreciated.
>
> OK, I figured this one out:
>
> cmap %/ ^R%^F$F/lC
>
> works as expected, and I thank you for it (there was a missing $). But
> it would be really really useful if it copied this command back to the
> Ex command line and not in a separate Ex buffer. That way I could use
> tab and vim would autocomplete the filename for me.
>
> So once again, thanks a lot, but I would appreciate if you could tell
> me a way to copy this back to the Ex command line (from the Ex history
> buffer).
>
> Thanks,
>
> >
> > Thanks,
> >
> >
> >
> > > the control characters ^R and ^F can be entered as digraphs (see :help
> > > digraphs, :help CTRL-k, and :digraphs) using these keystrokes:
> >
> > > ^R - <C-k>D2
> > > ^F - <C-k>AK
> >
> > > the mapping will cause the following to occur when you enter %/ in the
> Ex
> > > command line:
> >
> > > 1) ^R% causes the current filename to be inserted at the current cursor
> > > location
> > > 2) ^F switches to cmdwin mode (see :help cmdwin) which lets us use
> normal
> > > mode commands to edit the command line
> > > 3) F/ finds the first slash before the cursor (this mapping assumes
> that the
> > > full path of the file you are editing contains a slash)
> > > 4) lC (that's a lowercase "L") moves the cursor to the right, deletes
> the
> > > text after, and leaves you in insert mode.
> >
> > > enjoy! :)
> >
> > > On Fri, Nov 14, 2008 at 2:54 PM, madiyaan <[EMAIL PROTECTED]>
> wrote:
> >
> > > > Hello:
> >
> > > > Is there a way to open a file relative to the current file's
> > > > directory?
> >
> > > > I do not want to change the directory to the current file's directory
> > > > because I often invoke :!make from the source directory's root. (But
> > > > maybe there is a way to change to the current directory, and go back
> > > > to the root directory before invoking main... that would be equally
> > > > useful to me).
> >
> > > > For example, I am in project/ and I invoke:
> >
> > > > vim lib/tools/tool1.cpp
> >
> > > > I don't want to change my directory to project/lib/tools/ because
> when
> > > > I invoke :!make, it will use the Makefile in project/lib/tools/ and
> > > > not the one that I intend to use, which lies in project/. I am
> wanting
> > > > to know whether I can easily open up project/lib/tools/tool2.cpp
> > > > without typing in the entire path.
> >
> > > > Regards,
> >
> > > --
> > > Christopher Suter
> >
>


-- 
Christopher Suter

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to