ai.vim
1.0.0
简约的Neovim插件,用于使用OpenAI和GPT生成和编辑文本。
<Ctrl-A>
或运行:AI <prompt>
即可。对于VIM插头,将其添加到您的init.vim:
Plug ' aduros/ai.vim '
确保您有一个称为$OPENAI_API_KEY
的环境变量,您可以在此处生成。您还需要安装curl
。
要查看完整的帮助和自定义选项,请运行:help ai.vim
。
最基本的用例是完成,通过在插入模式下按<Ctrl-A>
。
例如:
function capitalize ( str : string ) : string {
( Press < Ctrl - A > here )
}
将导致:
function capitalize ( str : string ) : string {
return str . charAt ( 0 ) . toUpperCase ( ) + str . slice ( 1 ) ;
}
ai.vim不仅用于编程!您也可以完成常规的人类文字:
Hey Joe, here are some ideas for slogans for the new petshop. Which do you like best?
1. <Ctrl-A>
结果:
Hey Joe, here are some ideas for slogans for the new petshop. Which do you like best?
1. "Where Pets Come First!"
2. "Your Pet's Home Away From Home!"
3. "The Best Place for Your Pet!"
4. "The Pet Store That Cares!"
5. "The Pet Store That Loves Your Pet!"
您还可以通过在正常模式下按<Ctrl-A>
来生成一些文本并提供提示。例如:
:AI write a thank you email to Bigco engineering interviewer
结果类似:
Dear [Name],
I wanted to take a moment to thank you for taking the time to interview me for the engineering
position at Bigco. I was very impressed with the company and the team, and I am excited about the
possibility of joining the team.
I appreciate the time you took to explain the role and the company's mission. I am confident that I
have the skills and experience to be a valuable asset to the team.
Once again, thank you for your time and consideration. I look forward to hearing from you soon.
Sincerely,
[Your Name]
除了生成新文本外,您还可以使用给定的指令编辑现有文本。
body {
color : orange;
background : green;
}
视觉上选择上述CSS并运行:AI convert colors to hex
结果:
body {
color : # ffa500 ;
background : # 008000 ;
}
文本编辑的另一个示例:
List of capitals:
1. Toronto
2. London
3. Honolulu
4. Miami
5. Boston
视觉上选择此文本和运行:AI sort by population
会导致:
List of capitals:
1. London
2. Toronto
3. Boston
4. Miami
5. Honolulu
您可以为长而复杂的提示构建自己的快捷方式。例如:
vnoremap <silent> <leader> f :AI fix grammar and spelling and replace slang and contractions with a formal academic writing style <CR>
使用此自定义映射,您可以选择看起来像这样的文本:
Me fail English? That's unpossible!
并按下<leader>f
将其转换为以下方式:
I failed English? That is impossible!
如果您想出使用AI.VIM的任何令人兴奋的方法,请分享您发现的内容!
准确性:GPT擅长生产看起来正确的文本和代码,但可能完全是错误的。确保您通过此插件仔细证明阅读并测试所有输出!
隐私:此插件在生成完成和编辑时将文本发送到OpenAI。不要在包含敏感信息的文件中使用它。