If you want to execute some apex code, you either use developer console or workbench. It is always a pain to connect workbench with login credentials since it become inactive after being idle. Moreover, the code or query executed is not saved and you need to write it again.
VS Code has a useful feature to Execute Apex anonymou code from Visual Studio Code
- Open a new file
2. Write your code you want to execute like as shown below
3. Click Control+Shift+P or Click View->Command Palette and choose SFDX > Execute anonymous Apex with Editor Contents
The code will execute and shown on the output window
You can save the temp file if you want to run it later.
Moreover, if your file has a lot of code, you can select a part of it and using the same command, only selected/highlighted part will execute.