Wednesday, July 20, 2011

Re: How to get the directory name of the current file

何聪辉 wrote on 20/07/2011 09:29 AM:
> Hi, I am using vim as the simple IDE, and use qmake and make tool to
> configure my project. If a directory named "Foo", and inside the
> directory, there exists some headers and source files, I use the
> command "qmake -project", and it will generate a file called
> "Foo.pro", After I type "qmake", it will automatically generate the
> Makefile that I want, and by default, the target of the Makefile is
> the name of the directory, that is, "Foo". Now I want to do some
> mapping, say map <C-F5> to execute the executable file, "Foo". So I
> need to get the name of the directory. How can i achieve that?
>
> --
> Rice
> Tel: (+86)13450219269
> Email: heconghui@gmail.com <mailto:heconghui@gmail.com>
>

Try expand("%:h")

I found this by using :helpgrep directory and looking around a bit.
After a helpgrep, it's useful to load the quickfix window in order to do
a quicker scan. To view the quickfix window, use :cwindow.

HTH

--

.----------------------------------------------------------.
| Albie Janse van Rensburg |
| Respect! ~ http://www.dtcc.edu/cs/rfc1855.html |
'----------------------------------------------------------'

Superstition, idolatry, and hypocrisy have ample wages, but truth goes
a-begging.
-- Martin Luther

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment