ปลั๊กอิน NeoVim ที่เรียบง่ายสำหรับการสร้างและแก้ไขข้อความโดยใช้ OpenAI และ GPT
<Ctrl-A>
หรือเรียกใช้ :AI <prompt>
สำหรับ vim-plug ให้เพิ่มสิ่งนี้ลงใน 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 เมื่อสร้างความสำเร็จและการแก้ไข อย่าใช้ในไฟล์ที่มีข้อมูลที่ละเอียดอ่อน