Skip to content

Instantly share code, notes, and snippets.

@lorenzleutgeb
Created April 20, 2023 12:49
Show Gist options
  • Save lorenzleutgeb/2c76e24f15ea70d4f1102bbd5111d4e2 to your computer and use it in GitHub Desktop.
Save lorenzleutgeb/2c76e24f15ea70d4f1102bbd5111d4e2 to your computer and use it in GitHub Desktop.
:: The first argument is always "-C", since
:: External Editor Revived thinks that this
:: process is bash.
set target=%2
:: The following two lines can be used to
:: convert the argument to a WSL path.
::set target=%target:\\=/%
::set target=%target:C:=/mnt/c%
:: Unescape backslashes in path.
set target=%target:\\=/%
:: For debugging, echo the target path to vim.
::wt wsl bash -c "echo \""%target%\"" | vim"
:: Use vim inside WSL and Windows Terminal.
:: This currently does not work because
:: Windows Terminal won't wait for vim
:: to exit.
:: See https://github.com/microsoft/terminal/issues/8856
::wt wsl vim %target%
:: An editor that should always be available for debugging.
::notepad %target%
:: Touch the file, so that saving with VS Code vim
:: does not complain about ENONT.
::copy nul %target%
:: Run VS Code.
code --reuse-window --wait %target%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment