2

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 ...

1
  • May I ask you what's the meaning of tcd? Commented Mar 27, 2021 at 5:32

2 Answers 2

2

I don't have tcd installed, so untested:

nnoremap <leader>tcd :execute "tcd " . getcwd()<CR>:pwd<CR>
Sign up to request clarification or add additional context in comments.

2 Comments

May I ask you what's the meaning of tcd?
@Rainning It’s a command from a plug-in github.com/vim-scripts/tcd.vim
0

: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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.