uloco
uloco

Reputation: 2421

Run vim function inside ex command

I want to switch the current working directory of the tab to the current global working directory. How do I do that as a mapping?

I tried to make a mapping as follows

nnoremap <leader>tcd :tcd getcwd()<CR>:pwd<CR>

But it looks like :tcd expects a path. How do I evaluate getcwd() inside so it returns the path as a string?

Tried echo and call but it seems like I am doing it wrong ...

Upvotes: 2

Views: 270

Answers (2)

delfunc
delfunc

Reputation: 9

:exec to execute a string as a vim exec command so :exec 'tcd '.

:call system() to get the output of a shell command, but i don't see how getcwd is going to get anything different than the vim :pwd command or the shell ls command.

Upvotes: 0

Ralf
Ralf

Reputation: 1813

I don't have tcd installed, so untested:

nnoremap <leader>tcd :execute "tcd " . getcwd()<CR>:pwd<CR>

Upvotes: 2

Related Questions