Skip to content

Instantly share code, notes, and snippets.

@pfernandez
Last active June 29, 2023 11:03
Show Gist options
  • Save pfernandez/b807b8d47f3cbcdcc07501714d250085 to your computer and use it in GitHub Desktop.
Save pfernandez/b807b8d47f3cbcdcc07501714d250085 to your computer and use it in GitHub Desktop.
Command-click a file in iTerm2 to open it in an existing instance of Neovim
  1. Install neovim: brew install neovim
  2. Install neovim-remote: pip3 install neovim-remote
  3. In iTerm2, go to Preferences -> Profiles -> Advanced, select Semantic History -> Run coprocess, and paste this in:
n=/usr/local/bin/nvr; s="$n --serverlist | tail -n1"; c="$n --servername `$s` --remote-silent"; [ -z "\2" ] && $c \1 || $c +\2 \1

Then command-click a filepath (with optional line number) in iTerm to open the file. Neovim must already be open, and the most recently opened running instance will be used.

You can also achieve this with macvim, but only neovim works in the terminal.

💥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment