vhoyer
vhoyer

Reputation: 774

How to change vim working directory when navigating on NERDtree

in NERDtree if you press C it changes the root of the NERDtree for the folder under the cursor. i'd like to change vim's working directory (like when you use: :lcd \path\to\directory) by using this command. anyone knows a way of doing it??

Upvotes: 4

Views: 1710

Answers (1)

GiftZwergrapper
GiftZwergrapper

Reputation: 2752

You can set the option NERDTreeChDirMode to value 2 this will change vim's CWD when the tree root is changed.

'NERDTreeChDirMode'

Values: 0, 1 or 2. Default: 0.

Use this option to tell the script when (if at all) to change the current working directory (CWD) for vim.

If it is set to 0 then the CWD is never changed by the NERD tree.

If set to 1 then the CWD is changed when the NERD tree is first loaded to the directory it is initialized in. For example, if you start the NERD tree with :NERDTree /home/marty/foobar

then the CWD will be changed to /home/marty/foobar and will not be changed again unless you init another NERD tree with a similar command.

If the option is set to 2 then it behaves the same as if set to 1 except that the CWD is changed whenever the tree root is changed. For example, if the CWD is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new root then the CWD will become /home/marty/foobar/baz.

Upvotes: 4

Related Questions