Skip to content

Instantly share code, notes, and snippets.

@mordr
Last active May 17, 2024 02:44
Show Gist options
  • Save mordr/3c2df494c690672247c720f66f0fb613 to your computer and use it in GitHub Desktop.
Save mordr/3c2df494c690672247c720f66f0fb613 to your computer and use it in GitHub Desktop.
Set Visual Studio Code as default editor for kubectl

Set KUBE_EDITOR to Visual Studio Code, assumes 'code' is in PATH

export KUBE_EDITOR='code --wait'

Running k edit ... will open up the yaml using Visual Studio Code.

@mousavian
Copy link

mousavian commented Jun 14, 2019

EDITOR='open -a "Visual Studio Code" --wait' kubectl

^ inline temporary editor change for mac users

@MajorBreakfast
Copy link

@mousavian kubeclt?

@bodinsamuel
Copy link

thanks 🙏

@elgammalqa
Copy link

Thanks

@officialdarnyc
Copy link

Thanks

@ashconnell
Copy link

Legend!

@MissakaI-ObjectOne
Copy link

For PowerShell use
$env:KUBE_EDITOR="code --wait"

@willyg123
Copy link

willyg123 commented Jun 23, 2022

To make this permanent, edit ~/.bash-profile with code ~/.bash-profile and enter this into it:

export KUBE_EDITOR='code --wait'

@azerafati
Copy link

indeed opens up vscode just fine, but ‌I‌ can't make a change and save it. it says Edit cancelled, no changes made. tried it with --wait flag

@allidoiswin10
Copy link

Awesome!

@AL1L
Copy link

AL1L commented Jan 25, 2024

Thank

@vegetablest
Copy link

On macOS, has anyone encountered the problem that closing the editing page will not save the changes, and need to exit the vscode process to save the changes.

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