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。不要在包含敏感信息的文件中使用它。