Vortex is an open-source VS Code extension that uses the power of GPT to enhance and edit code directly within the VS Code editor. With Vortex, you can leverage the power of AI to write better code, faster.
To use Vortex, you will need:
- Visual Studio Code
- A valid OpenAI API key
You can fetch your OpenAI API key at https://platform.openai.com/account/api-keys.
To get started with Vortex, simply install the extension from the VScode Marketplace. Once installed, Vortex will be available in the editor and can be used to generate, edit or review your code.
NOTE: This extension uses VS Code's Secret Storage to safely store API keys, and not in the user settings, which is something that is readable for all other extensions in the workspace.
When the extension activates, you will see a prompt to enter your OpenAI API key, enter the key here and the extension will be ready to use.
Vortex can help generate, edit or review code.
As an example, to use Vortex to edit code, follow these simple steps:
- Select the code you want to edit in the editor. If you don't select anything, the entire file contents will be chosen as the selection. (Refer
Extension Settings
below to understand how to configure Vortex to not process too many lines). - Open the VScode Command Palette (press
Ctrl+Shift+P
orCmd+Shift+P
on Mac). - Type
Vortex: Edit Code
and press enter to execute the command. - A prompt will appear asking you to describe the edits you want to make. Enter a brief description of the changes you want Vortex to make (e.g.
Add a docstring
), and press enter.
That's it! Vortex will automatically apply the requested edits, saving you time and effort. If you're not happy with the suggested edits, you can always modify your description and generate new suggestions until you find the changes you're looking for.
You can follow similar steps to use the Generate Code
and Review Code
commands.
Assume you have the following function:
def get_grade(score):
if score >= 90:
grade = 'A'
elif score >= 80:
grade = 'B'
elif score >= 70:
grade = 'C'
else:
grade = 'D'
return grade
After performing a Vortex: Edit Code
followed by the edit description: Use dict instead of if else
, Vortex automatically updates the code to:
def get_grade(score):
grade = {
score >= 90: 'A',
score >= 80: 'B',
score >= 70: 'C',
True: 'D'
}
return grade[True]
Here are a few samples of commands followed by descriptions for common use cases:
Generating code: Generate Code
-> Util function to make API calls
Docstring generation: Edit Code
-> Docstring
or Add Docstring
.
Refactoring: Edit Code
-> Better variable names
.
Code Reviews: Review Code
This extension contributes the following settings:
vortex.maxLinesToProcess
: Use this to set the maximum number of lines to be processed. This is to make sure that you don't accidentally run this on a huge piece of code, which will end up using tokens from your OpenAI account. Default value is20
.vortex.requestTimeout
: Maximum number of seconds to wait for the API to respond. Default value is10
.vortex.autoFormat
: Auto format the document post generating or editing code. Default value istrue
.
Each command has a corresponding keybinding by default:
Generate Code: Ctrl+J Ctrl+G
Edit Code: Ctrl+J Ctrl+E
Review Code: Ctrl+J Ctrl+R
Vortex is licensed under the MIT License. See the LICENSE file for more information.
Enjoy!