Add export EDITOR="code -w" to your shell’s profile or rc file
(For example, your bash profile is accessible via open ~/.bash_profile)
This requires you to have the code binary already in your path.
If you don’t have that, or don’t know if you do, simply go into vscode, enter CMD + SHIFT + P, type code and click Shell Command: Install ‘code’ command in PATH.
Also, very helpful comment by pompalini below,
remember to “refresh” terminal by closing and opening it again or resourcing your bash profile by running
source ~/.bash_profile. Only then will the new changes in.bash_profileapply to your terminal.