5

I want to have vim .vimrc do something like:

let root = :pwd

and the variable root will have memorized that "pwd" that vim was in at that moment. How do I do this?

Another person asked this question, but another solution was found, so the question was never really answered (http://stackoverflow.com/questions/2540524/vim-call-an-ex-command-set-from-function)

Using variables

Also, once I assign root to a value, how do I do the following:

:cd root

Every time I do that, vim gives me the following error:

E344: Can't find directory "root" in cdpath
E472: Command failed
Alexander Bird
  • 38,679
  • 42
  • 124
  • 159

1 Answers1

6
:let root = getcwd()
:exe 'cd ' . root

There are probably nicer ways to do this (especially the last part) but it works.

alexaandru
  • 131
  • 1
  • 1
  • 4