dirname

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

dirname

iler.ml

What is vimscript analog of dirname() function (cf per, bash).
I tried

  let path = "/home/joe/.vimrc"
  echo expand(  path . ":h" )

But it does not work as expected.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dirname

Christian Brabandt

On Tue, March 17, 2009 11:20 am, Yakov wrote:
>
> What is vimscript analog of dirname() function (cf per, bash).
> I tried
>
>   let path = "/home/joe/.vimrc"
>   echo expand(  path . ":h" )
>
> But it does not work as expected.

echo fnamemodify(expand(path), ":h")

regards,
Christian
--
:wq


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

Reply | Threaded
Open this post in threaded view
|

Re: dirname

Benjamin Fritz



On Mar 17, 5:33 am, "Christian Brabandt" <[hidden email]> wrote:


>
> echo fnamemodify(expand(path), ":h")
>

I don't think you actually need the expand() at all. Just use:

echo fnamemodify(path, ":p:h")
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: dirname

Christian Brabandt

Hi Ben!

On Wed, 18 Mar 2009, Ben Fritz wrote:

> On Mar 17, 5:33 am, "Christian Brabandt" <[hidden email]> wrote:
> >
> > echo fnamemodify(expand(path), ":h")
> >
>
> I don't think you actually need the expand() at all. Just use:
>
> echo fnamemodify(path, ":p:h")

No you don't, just in case your path contains an environment variable
like $HOME.

regards,
Christian
--
:wq!

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