Skip to content

KarateJB/vim-openai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-openai

vim-openai is a Vim plugin to integrate OpenAI API.

Features

  • ChatGPT: Text Completion

Install

Just use your Vim plugin manager to install the plugin, or clone this repository into plugin directory, such as ~/.vim/pack/bundle/start/.

Options

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.

How to use

Input prompt in Command Mode

:Chatgpt "List the 3 popular NBA players"

It will open a new buffer and show the completion response.

Input prompt from current buffer

When there is no argument, the command Chatgpt takes current buffer's all content as prompt to ChatGPT.

:Chatgpt

Input prompt from selection

When in Visual Mode, we can pass the selected text as prompt to ChatGPT by command ChatgptSelection.

:'<,'>ChatgptSelection

Demo

License

Copyright (c) KarateJB. Distributed under the same terms as Vim itself. See :help license.

About

Vim plugin to integrate OpenAI API and use its function without leaving Vim.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published