VIM replace part of filename with something else similar to ZSH cd

Viewed 117

I have recently switched to using VIM. I work on multiple branches of the same code so often two files will have very similar paths (example: /home/user/turkey/code/helloworld.cpp) and I would like to diff the same file in another branch (example: /home/user/kangaroo/code/helloworld.cpp).

ZSH has cd command where one can just say cd turkey kangaroo to change the path. I would like to find/create something similar in my vimrc (example: diffsplit vert turkey kangaroo). Any suggestions on how to go about this?

I know that the full path to the current file is stored in expand('%:p') but am not sure how I would go about changing the contents of this. It seems like the vim replace is limited to editing files rather than registers. I would like to do this in memory instead of having it edit a file.

1 Answers
Related