https://github.com/kelvins/vim-gpt
:robot: GPT plugin for Vim
https://github.com/kelvins/vim-gpt
ai gpt plugin vim
Last synced: 3 months ago
JSON representation
:robot: GPT plugin for Vim
- Host: GitHub
- URL: https://github.com/kelvins/vim-gpt
- Owner: kelvins
- Created: 2023-04-02T23:51:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-08T18:47:08.000Z (over 2 years ago)
- Last Synced: 2025-05-08T02:48:44.551Z (5 months ago)
- Topics: ai, gpt, plugin, vim
- Language: Vim Script
- Homepage:
- Size: 2.11 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# gpt.vim
A Vim plugin for using Generative Pre-trained Transformer (GPT) from OpenAI API.

## Installation
[vim-plug](https://github.com/junegunn/vim-plug)
```
Plug 'kelvins/vim-gpt'
```[Vundle](https://github.com/VundleVim/Vundle.vim)
```
Plugin 'kelvins/vim-gpt'
```### Dependencies
- `curl`: to execute HTTP requests to the OpenAI API.
- `jq`: to parse JSON responses.### Environment Variable
To use the OpenAI API you will need an API key. To get an API key, go to OpenAI platform web site ([here](https://platform.openai.com/account/api-keys)), create an account and generate the API key. Now, set the API key in the `$OPENAI_API_KEY` environment variable, for example:
```
export OPENAI_API_KEY=s4jyM5kSMbw7MG6Uqv3bw3T3B4b4F6X9pLpz36vr8eaKzXPC
```## Usage
In Vim normal mode just type `:GPT` and an input prompt will be displayed, just type the content you want to send and hit `Enter`, for example:
```
Prompt: Write a Hello World function in Rust
```It will open a popup window with a response preview so you can type `q` to ignore and close the popup or `w` to close the popup and copy the content to the current buffer.
### Tip
You can map a shortcut like `ctrl + g`, in your `~/.vimrc` file, to open the prompt, for example:
```
nnoremap :GPT
```## Disclaimers
This plugin uses the OpenAI API, so be careful with sensitive information.
GPT doesn't always give correct answers, remember to double check any text or code generated by the AI.
## Contributing
All contributions are welcome! Please take a look at the [contribution guidelines](CONTRIBUTING.md) first.