Last Updated: February 22, 2021
· Lorin Hochstein

iterm2 cmd-click to open file in vim in terminal

This will enable you to cmd-click on a filename in iTerm2 and have it launch vim within the same iterm2 window:

Click on: Preferences -> Profiles -> Advanced

Under "Semantic History", choose "Run coprocess..". In the text field, put:

echo vim \1 +\2


1 Response
Add your response

Thank you so much for the tip, I was finally looking at a way of doing that today after many years of frustration having xcode open when clicking on a .py file.
I made a little improvement to add the line number only if it's present (otherwise a single + takes you to the end of the file):

echo vim \1 $(if [[ "\2" =~ ^[0-9]+$ ]]; then echo "+\2";fi)
over 1 year ago ·