vim-openai is a Vim plugin to integrate OpenAI API.
- ChatGPT: Text Completion
Just use your Vim plugin manager to install the plugin, or clone this repository into plugin directory, such as ~/.vim/pack/bundle/start/
.
Set the following variables in your vimrc file.
Variable | Type | Required | Description |
---|---|---|---|
g:chatgpt_apikey | string | required | Your API key. |
g:chatgpt_maxtoken | number | optional | The number of max token. The default value is 1000 . |
g:chatgpt_focus_result | boolean | optional | 0: go back to the last edit buffer, 1: move the cursor to the new buffer with result. The default value is 0 . |
:Chatgpt "List the 3 popular NBA players"
It will open a new buffer and show the completion response.
When there is no argument, the command Chatgpt
takes current buffer's all content as prompt to ChatGPT.
:Chatgpt
When in Visual Mode, we can pass the selected text as prompt to ChatGPT by command ChatgptSelection
.
:'<,'>ChatgptSelection
Copyright (c) KarateJB. Distributed under the same terms as Vim itself. See :help license
.