46

I'm currently adding a little bit of Git functionality to my menu.vim file, and for using a certain command (Gitk) I need to find out Vim's current directory.

How does one do that and include it in a command? (i.e. :!echo "%current-directory")


I'll admit here that I asked the wrong question - but I figured it out.

I'm currently using these in my menu.vim:

function g:Gitk()
  :!cd $(dirname %); gitk
endfun

function g:GitGui()
  :!cd $(dirname %); git gui
endfun
new123456
  • 575
  • 1
  • 4
  • 9

1 Answers1

74

I think either :pwd or getcwd() is what you are looking for.


Just to help memorize things:

:pwd => print working directory

getcwd() => get current working directory

Anthony Geoghegan
  • 12,605
  • 7
  • 59
  • 62
davitenio
  • 2,126
  • 1
  • 14
  • 4