{"id":13479645,"url":"https://github.com/madox2/vim-ai","last_synced_at":"2025-05-15T01:06:21.215Z","repository":{"id":153133101,"uuid":"607355225","full_name":"madox2/vim-ai","owner":"madox2","description":"AI-powered code assistant for Vim. OpenAI and ChatGPT plugin for Vim and Neovim.","archived":false,"fork":false,"pushed_at":"2025-05-09T21:45:23.000Z","size":16361,"stargazers_count":922,"open_issues_count":4,"forks_count":90,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-09T22:29:57.692Z","etag":null,"topics":["chatgpt","code-generation","gemini","gpt-4","llm","neovim","openai","vim"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/madox2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-27T20:23:49.000Z","updated_at":"2025-05-09T21:45:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"b838a55f-aef1-4561-a483-0b321e909a09","html_url":"https://github.com/madox2/vim-ai","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madox2%2Fvim-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madox2%2Fvim-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madox2%2Fvim-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/madox2%2Fvim-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/madox2","download_url":"https://codeload.github.com/madox2/vim-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254254040,"owners_count":22039792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","code-generation","gemini","gpt-4","llm","neovim","openai","vim"],"created_at":"2024-07-31T16:02:20.728Z","updated_at":"2025-05-15T01:06:16.207Z","avatar_url":"https://github.com/madox2.png","language":"Python","funding_links":[],"categories":["Browser-extensions","Python","IDE Extensions","13. Developer Tools \u0026 Integrations","Code writing and editing","🚀 AI Tools for Vim, Neovim, and Terminal","Addons, extensions, plug-ins for integrating LLM into third-party applications"],"sub_categories":["Neovim/Vim","Other user interfaces"],"readme":"# vim-ai\n\nThis plugin adds Artificial Intelligence (AI) capabilities to your Vim and Neovim.\nYou can generate code, edit text, or have an interactive conversation with GPT models, all powered by OpenAI's API.\n\n![vim-ai demo](./demo.gif)\n\nTo get an idea what is possible to do with AI commands see the [prompts](https://github.com/madox2/vim-ai/wiki/AI-prompts#prompts) on the [Community Wiki](https://github.com/madox2/vim-ai/wiki)\n\n## Features\n\n- Generate text or code, answer questions with AI\n- Edit selected text in-place with AI\n- Interactive conversation with ChatGPT\n- Custom roles\n- Vision capabilities (image to text)\n- Generate images\n- Integrates with any OpenAI-compatible API\n- AI provider plugins\n\n## How it works\n\nThis plugin uses OpenAI's API to generate responses.\nYou will need to [setup](https://platform.openai.com/signup) an account and obtain an [API key](https://platform.openai.com/account/api-keys).\nUsage of the API is not free, but the cost is reasonable and depends on how many tokens you use, in simple terms, how much text you send and receive (see [pricing](https://openai.com/pricing)).\nNote that the plugin does not send any of your code behind the scenes.\nYou only share and pay for what you specifically select, for prompts and chat content.\n\nIn case you would like to experiment with Gemini, Claude or other models running as a service or locally, you can use any OpenAI compatible proxy.\nA simple way is to use [OpenRouter](https://openrouter.ai) which has a fair pricing (and currently offers many models for [free](https://openrouter.ai/models?max_price=0)), or setup a proxy like [LiteLLM](https://github.com/BerriAI/litellm) locally.\nSee this simple [guide](#example-create-custom-roles-to-interact-with-openrouter-models) on configuring custom OpenRouter roles.\n\n🚨 **Announcement** 🚨\n\n`vim-ai` can now be extended with custom provider plugins.\nHowever, there aren't many available yet, so developing new ones is welcome!\nFor more, see the [providers](#providers) section.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Providers](#providers)\n- [Roles](#roles)\n- [Reference](#reference)\n- [Configuration](#configuration)\n- [Key bindings](#key-bindings)\n- [Custom commands](#custom-commands)\n\n## Installation\n\n### Prerequisites\n\n- Vim or Neovim compiled with python3 support\n- [API key](https://platform.openai.com/account/api-keys)\n\n```sh\n# save api key to `~/.config/openai.token` file\necho \"YOUR_OPENAI_API_KEY\" \u003e ~/.config/openai.token\n\n# alternatively set it as an environment variable\nexport OPENAI_API_KEY=\"YOUR_OPENAI_API_KEY\"\n\n# or configure it with your organization id\necho \"YOUR_OPENAI_API_KEY,YOUR_OPENAI_ORG_ID\" \u003e ~/.config/openai.token\nexport OPENAI_API_KEY=\"YOUR_OPENAI_API_KEY,YOUR_OPENAI_ORG_ID\"\n```\n\nThe default api key file location is `~/.config/openai.token`, but you can change it by setting the `g:vim_ai_token_file_path` in your `.vimrc` file:\n\n```vim\nlet g:vim_ai_token_file_path = '~/.config/openai.token'\n```\n\n### Using `vim-plug`\n\n```vim\nPlug 'madox2/vim-ai'\n```\n\n### Manual installation\n\nUsing built-in Vim packages `:help packages`\n\n```sh\n# vim\nmkdir -p ~/.vim/pack/plugins/start\ngit clone https://github.com/madox2/vim-ai.git ~/.vim/pack/plugins/start/vim-ai\n\n# neovim\nmkdir -p ~/.local/share/nvim/site/pack/plugins/start\ngit clone https://github.com/madox2/vim-ai.git ~/.local/share/nvim/site/pack/plugins/start/vim-ai\n```\n\n## Usage\n\nTo use an AI command, type the command followed by an instruction prompt. You can also combine it with a visual selection. Here is a brief overview of available commands:\n\n```\n========== Basic AI commands ==========\n\n:AI       complete text\n:AIEdit   edit text\n:AIChat   continue or open new chat\n:AIImage  generate image\n\n============== Utilities ==============\n\n:AIRedo          repeat last AI command\n:AIUtilRolesOpen open role config file\n:AIUtilDebugOn   turn on debug logging\n:AIUtilDebugOff  turn off debug logging\n\n:help vim-ai\n```\n\n**Tip:** Press `Ctrl-c` anytime to cancel completion\n\n**Tip:** Use command shortcuts - `:AIE`, `:AIC`, `:AIR`, `:AII` or setup your own [key bindings](#key-bindings)\n\n**Tip:** Define and use [custom roles](#roles), e.g. `:AIEdit /grammar`.\n\n**Tip:** Use pre-defined roles `/right`, `/below`, `/tab` to choose how chat is open, e.g. `:AIC /right`\n\n**Tip:** Use special role `/populate` to dump options to chat header, e.g. `:AIC /populate /gemini`\n\n**Tip:** Combine commands with a range `:help range`, e.g. to select the whole buffer - `:%AIE fix grammar`\n\nIf you are interested in more tips or would like to level up your Vim with more commands like [`:GitCommitMessage`](https://github.com/madox2/vim-ai/wiki/Custom-commands#suggest-a-git-commit-message) - suggesting a git commit message, visit the [Community Wiki](https://github.com/madox2/vim-ai/wiki).\n\n## Providers\n\nThis is the list of 3rd party provider plugins allowing to use different AI providers.\n\n- [google provider](https://github.com/madox2/vim-ai-provider-google) - Google's Gemini models\n\nIn case you are interested in developing one, have a look at reference [google provider](https://github.com/madox2/vim-ai-provider-google).\nDo not forget to open PR updating this list.\n\n## Roles\n\nIn the context of this plugin, a role means a re-usable AI instruction and/or configuration. Roles are defined in the configuration `.ini` file. For example by defining a `grammar` and `o1-mini` role:\n\n```vim\nlet g:vim_ai_roles_config_file = '/path/to/my/roles.ini'\n```\n\n```ini\n# /path/to/my/roles.ini\n\n[grammar]\nprompt = fix spelling and grammar\noptions.temperature = 0.4\n\n[o1-mini]\noptions.stream = 0\noptions.model = o1-mini\noptions.max_completion_tokens = 25000\noptions.temperature = 1\noptions.initial_prompt =\n```\n\nNow you can select text and run it with command `:AIEdit /grammar`.\n\nYou can also combine roles `:AI /o1-mini /grammar helo world!`\n\nSee [roles-example.ini](./roles-example.ini) for more examples.\n\n## Reference\n\nIn the documentation below,  `\u003cselection\u003e` denotes a visual selection or any other range, `{instruction}` an instruction prompt, `{role}` a [custom role](#roles) and `?` symbol an optional parameter.\n\n### `:AI`\n\n`:AI {prompt}` - complete the prompt\n\n`\u003cselection\u003e :AI` - complete the selection\n\n`\u003cselection\u003e :AI {instruction}` - complete the selection using the instruction\n\n`\u003cselection\u003e? :AI /{role} {instruction}?` - use role to complete\n\n### `:AIEdit`\n\n`\u003cselection\u003e? :AIEdit` - edit the current line or the selection\n\n`\u003cselection\u003e? :AIEdit {instruction}` - edit the current line or the selection using the instruction\n\n`\u003cselection\u003e? :AIEdit /{role} {instruction}?` - use role to edit\n\n### `:AIImage`\n\n`:AIImage {prompt}` - generate image with prompt\n\n`\u003cselection\u003e :AIImage` - generate image with seleciton\n\n`\u003cselection\u003e? :AI /{role} {instruction}?` - use role to generate\n\n[Pre-defined](./roles-default.ini) image roles: `/hd`, `/natural`\n\n### `:AIChat`\n\n`:AIChat` - continue or start a new conversation.\n\n`\u003cselection\u003e? :AIChat {instruction}?` - start a new conversation given the selection, the instruction or both\n\n`\u003cselection\u003e? :AIChat /{role} {instruction}?` - use role to complete\n\nWhen the AI finishes answering, you can continue the conversation by entering insert mode, adding your prompt, and then using the command `:AIChat` once again.\n\n[Pre-defined](./roles-default.ini) chat roles: `/right`, `/below`, `/tab`\n\n#### `.aichat` files\n\nYou can edit and save the chat conversation to an `.aichat` file and restore it later.\nThis allows you to create re-usable custom prompts, for example:\n\n```\n# ./refactoring-prompt.aichat\n\n\u003e\u003e\u003e system\n\nYou are a Clean Code expert, I have the following code, please refactor it in a more clean and concise way so that my colleagues can maintain the code more easily. Also, explain why you want to refactor the code so that I can add the explanation to the Pull Request.\n\n\u003e\u003e\u003e user\n\n[attach code]\n\n```\n\nTo include files in the chat a special `include` section is used:\n\n```\n\u003e\u003e\u003e user\n\nGenerate documentation for the following files\n\n\u003e\u003e\u003e include\n\n/home/user/myproject/requirements.txt\n/home/user/myproject/**/*.py\n```\n\nEach file's contents will be added to an additional user message with `==\u003e {path} \u003c==` header, relative paths are resolved to the current working directory.\n\n\nTo use image vision capabilities (image to text) include an image file:\n\n```\n\u003e\u003e\u003e user\n\nWhat object is on the image?\n\n\u003e\u003e\u003e include\n\n~/myimage.jpg\n```\n\nExecute command and include stdout into the chat:\n\n```\n\u003e\u003e\u003e user\n\nSuggest git commit message\n\n\u003e\u003e\u003e exec\n\ngit diff\n```\n\nSupported chat sections are **`\u003e\u003e\u003e system`**, **`\u003e\u003e\u003e user`**, **`\u003e\u003e\u003e include`**, **`\u003e\u003e\u003e exec`** and **`\u003c\u003c\u003c assistant`**\n\n### `:AIRedo`\n\n`:AIRedo` - repeat last AI command\n\nUse this immediately after `AI`/`AIEdit`/`AIChat` command in order to re-try or get an alternative completion.\nNote that the randomness of responses heavily depends on the [`temperature`](https://platform.openai.com/docs/api-reference/completions/create#completions/create-temperature) parameter.\n\n## Configuration\n\nEach command is configured with a corresponding configuration variable.\nTo customize the default configuration, initialize the config variable with a selection of options, for example put this to your`.vimrc` file:\n\n```vim\nlet g:vim_ai_chat = {\n\\  \"options\": {\n\\    \"model\": \"o1-preview\",\n\\    \"stream\": 0,\n\\    \"temperature\": 1,\n\\    \"max_completion_tokens\": 25000,\n\\    \"initial_prompt\": \"\",\n\\  },\n\\}\n```\n\nAlternatively you can use special `default` role:\n\n```ini\n[default.chat]\noptions.model = o1-preview\noptions.stream = 0\noptions.temperature = 1\noptions.max_completion_tokens = 25000\noptions.initial_prompt =\n```\n\nOr customize the options directly in the chat buffer:\n\n```properties\n[chat]\noptions.model = o1-preview\noptions.stream = 0\noptions.temperature = 1\noptions.max_completion_tokens = 25000\noptions.initial_prompt =\n\n\u003e\u003e\u003e user\n\ngenerate a paragraph of lorem ipsum\n```\n\nBelow are listed all available configuration options, along with their default values.\nPlease note that there isn't any token limit imposed on chat model.\n\n```vim\n\" This prompt instructs model to be consise in order to be used inline in editor\nlet s:initial_complete_prompt =\u003c\u003c trim END\n\u003e\u003e\u003e system\n\nYou are a general assistant.\nAnswer shortly, consisely and only what you are asked.\nDo not provide any explanantion or comments if not requested.\nIf you answer in a code, do not wrap it in markdown code block.\nEND\n\n\" :AI\n\" - provider: AI provider\n\" - prompt: optional prepended prompt\n\" - options: openai config (see https://platform.openai.com/docs/api-reference/completions)\n\" - options.initial_prompt: prompt prepended to every chat request (list of lines or string)\n\" - options.temperature: use -1 to disable this parameter\n\" - options.request_timeout: request timeout in seconds\n\" - options.auth_type: API authentication method (bearer, api-key, none)\n\" - options.token_file_path: override global token configuration\n\" - options.token_load_fn: expression/vim function to load token\n\" - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)\n\" - ui.paste_mode: use paste mode (see more info in the Notes below)\nlet g:vim_ai_complete = {\n\\  \"provider\": \"openai\",\n\\  \"prompt\": \"\",\n\\  \"options\": {\n\\    \"model\": \"gpt-4o\",\n\\    \"endpoint_url\": \"https://api.openai.com/v1/chat/completions\",\n\\    \"max_tokens\": 0,\n\\    \"max_completion_tokens\": 0,\n\\    \"temperature\": 0.1,\n\\    \"request_timeout\": 20,\n\\    \"stream\": 1,\n\\    \"auth_type\": \"bearer\",\n\\    \"token_file_path\": \"\",\n\\    \"token_load_fn\": \"\",\n\\    \"selection_boundary\": \"#####\",\n\\    \"initial_prompt\": s:initial_complete_prompt,\n\\  },\n\\  \"ui\": {\n\\    \"paste_mode\": 1,\n\\  },\n\\}\n\n\" :AIEdit\n\" - provider: AI provider\n\" - prompt: optional prepended prompt\n\" - options: openai config (see https://platform.openai.com/docs/api-reference/completions)\n\" - options.initial_prompt: prompt prepended to every chat request (list of lines or string)\n\" - options.temperature: use -1 to disable this parameter\n\" - options.request_timeout: request timeout in seconds\n\" - options.auth_type: API authentication method (bearer, api-key, none)\n\" - options.token_file_path: override global token configuration\n\" - options.token_load_fn: expression/vim function to load token\n\" - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)\n\" - ui.paste_mode: use paste mode (see more info in the Notes below)\nlet g:vim_ai_edit = {\n\\  \"provider\": \"openai\",\n\\  \"prompt\": \"\",\n\\  \"options\": {\n\\    \"model\": \"gpt-4o\",\n\\    \"endpoint_url\": \"https://api.openai.com/v1/chat/completions\",\n\\    \"max_tokens\": 0,\n\\    \"max_completion_tokens\": 0,\n\\    \"temperature\": 0.1,\n\\    \"request_timeout\": 20,\n\\    \"stream\": 1,\n\\    \"auth_type\": \"bearer\",\n\\    \"token_file_path\": \"\",\n\\    \"token_load_fn\": \"\",\n\\    \"selection_boundary\": \"#####\",\n\\    \"initial_prompt\": s:initial_complete_prompt,\n\\  },\n\\  \"ui\": {\n\\    \"paste_mode\": 1,\n\\  },\n\\}\n\n\" This prompt instructs model to work with syntax highlighting\nlet s:initial_chat_prompt =\u003c\u003c trim END\n\u003e\u003e\u003e system\n\nYou are a general assistant.\nIf you attach a code block add syntax type after ``` to enable syntax highlighting.\nEND\n\n\" :AIChat\n\" - provider: AI provider\n\" - prompt: optional prepended prompt\n\" - options: openai config (see https://platform.openai.com/docs/api-reference/chat)\n\" - options.initial_prompt: prompt prepended to every chat request (list of lines or string)\n\" - options.temperature: use -1 to disable this parameter\n\" - options.request_timeout: request timeout in seconds\n\" - options.auth_type: API authentication method (bearer, api-key, none)\n\" - options.token_file_path: override global token configuration\n\" - options.token_load_fn: expression/vim function to load token\n\" - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)\n\" - ui.open_chat_command: preset (preset_below, preset_tab, preset_right) or a custom command\n\" - ui.populate_options: dump [chat] config to the chat header\n\" - ui.scratch_buffer_keep_open: re-use scratch buffer within the vim session\n\" - ui.force_new_chat: force new chat window (used in chat opening roles e.g. `/tab`)\n\" - ui.paste_mode: use paste mode (see more info in the Notes below)\nlet g:vim_ai_chat = {\n\\  \"provider\": \"openai\",\n\\  \"prompt\": \"\",\n\\  \"options\": {\n\\    \"model\": \"gpt-4o\",\n\\    \"endpoint_url\": \"https://api.openai.com/v1/chat/completions\",\n\\    \"max_tokens\": 0,\n\\    \"max_completion_tokens\": 0,\n\\    \"temperature\": 1,\n\\    \"request_timeout\": 20,\n\\    \"stream\": 1,\n\\    \"auth_type\": \"bearer\",\n\\    \"token_file_path\": \"\",\n\\    \"token_load_fn\": \"\",\n\\    \"selection_boundary\": \"\",\n\\    \"initial_prompt\": s:initial_chat_prompt,\n\\  },\n\\  \"ui\": {\n\\    \"open_chat_command\": \"preset_below\",\n\\    \"scratch_buffer_keep_open\": 0,\n\\    \"populate_options\": 0,\n\\    \"force_new_chat\": 0,\n\\    \"paste_mode\": 1,\n\\  },\n\\}\n\n\" :AIImage\n\" - prompt: optional prepended prompt\n\" - options: openai config (https://platform.openai.com/docs/api-reference/images/create)\n\" - options.request_timeout: request timeout in seconds\n\" - options.auth_type: API authentication method (bearer, api-key, none)\n\" - options.token_file_path: override global token configuration\n\" - options.token_load_fn: expression/vim function to load token\n\" - options.download_dir: path to image download directory, `cwd` if not defined\nlet g:vim_ai_image = {\n\\  \"provider\": \"openai\",\n\\  \"prompt\": \"\",\n\\  \"options\": {\n\\    \"model\": \"dall-e-3\",\n\\    \"endpoint_url\": \"https://api.openai.com/v1/images/generations\",\n\\    \"quality\": \"standard\",\n\\    \"size\": \"1024x1024\",\n\\    \"style\": \"vivid\",\n\\    \"request_timeout\": 40,\n\\    \"auth_type\": \"bearer\",\n\\    \"token_file_path\": \"\",\n\\    \"token_load_fn\": \"\",\n\\  },\n\\  \"ui\": {\n\\    \"download_dir\": \"\",\n\\  },\n\\}\n\n\" custom roles file location\nlet g:vim_ai_roles_config_file = s:plugin_root . \"/roles-example.ini\"\n\n\" custom token file location\nlet g:vim_ai_token_file_path = \"~/.config/openai.token\"\n\n\" custom fn to load token, e.g. \"g:GetAIToken()\"\nlet g:vim_ai_token_load_fn = \"\"\n\n\" enables/disables full markdown highlighting in aichat files\n\" NOTE: code syntax highlighting works out of the box without this option enabled\n\" NOTE: highlighting may be corrupted when using together with the `preservim/vim-markdown`\ng:vim_ai_chat_markdown = 0\n\n\" debug settings\nlet g:vim_ai_debug = 0\nlet g:vim_ai_debug_log_file = \"/tmp/vim_ai_debug.log\"\n\n\" Notes:\n\" ui.paste_mode\n\" - if disabled code indentation will work but AI doesn't always respond with a code block\n\"   therefore it could be messed up\n\" - find out more in vim's help `:help paste`\n\" options.max_tokens\n\" - note that prompt + max_tokens must be less than model's token limit, see #42, #46\n\" - setting max tokens to 0 will exclude it from the OpenAI API request parameters, it is\n\"   unclear/undocumented what it exactly does, but it seems to resolve issues when the model\n\"   hits token limit, which respond with `OpenAI: HTTPError 400`\n\" options.selection_boundary\n\" - setting ``` value behaves in markdown-like fasion - adds filetype to the boundary\n\n### Using custom API\n\nIt is possible to configure the plugin to use different OpenAI-compatible endpoints.\nSee some cool projects listed in [Custom APIs](https://github.com/madox2/vim-ai/wiki/Custom-APIs) section on the [Community Wiki](https://github.com/madox2/vim-ai/wiki).\n\n```vim\nlet g:vim_ai_chat = {\n\\  \"options\": {\n\\    \"endpoint_url\": \"http://localhost:8000/v1/chat/completions\",\n\\    \"auth_type\": \"none\",\n\\  },\n\\}\n```\n\n#### Example: create custom roles to interact with OpenRouter models\n\nFirst you need open an account on [OpenRouter](https://openrouter.ai/) website and create an api key.\nYou can start with [free models](https://openrouter.ai/models?max_price=0) and add credits later if you wish.\nThen you set up a custom role that points to the OpenRouter endpoint:\n\n```ini\n[gemini]\noptions.token_file_path = ~/.config/openrouter.token\noptions.endpoint_url = https://openrouter.ai/api/v1/chat/completions\noptions.model = google/gemini-exp-1121:free\n\n[llama]\noptions.token_file_path = ~/.config/openrouter.token\noptions.endpoint_url = https://openrouter.ai/api/v1/chat/completions\noptions.model = meta-llama/llama-3.3-70b-instruct\n\n[claude]\noptions.token_file_path = ~/.config/openrouter.token\noptions.endpoint_url = https://openrouter.ai/api/v1/chat/completions\noptions.model = anthropic/claude-3.5-haiku\n```\n\nNow you can use the role:\n\n```\n:AI /gemini who created you?\n\nI was created by Google.\n```\n\n## Key bindings\n\nThis plugin does not set any key binding. Create your own bindings in the `.vimrc` to trigger AI commands, for example:\n\n```vim\n\" complete text on the current line or in visual selection\nnnoremap \u003cleader\u003ea :AI\u003cCR\u003e\nxnoremap \u003cleader\u003ea :AI\u003cCR\u003e\n\n\" edit text with a custom prompt\nxnoremap \u003cleader\u003es :AIEdit fix grammar and spelling\u003cCR\u003e\nnnoremap \u003cleader\u003es :AIEdit fix grammar and spelling\u003cCR\u003e\n\n\" trigger chat\nxnoremap \u003cleader\u003ec :AIChat\u003cCR\u003e\nnnoremap \u003cleader\u003ec :AIChat\u003cCR\u003e\n\n\" redo last AI command\nnnoremap \u003cleader\u003er :AIRedo\u003cCR\u003e\n```\n\n## Custom commands\n\nYou might find useful a [collection](https://github.com/madox2/vim-ai/wiki/Custom-commands) of custom commands on the [Community Wiki](https://github.com/madox2/vim-ai/wiki).\n\nTo create a custom command, you can call `AIRun`, `AIEditRun` and `AIChatRun` functions. For example:\n\n```vim\n\" custom command suggesting git commit message, takes no arguments\nfunction! GitCommitMessageFn()\n  let l:range = 0\n  let l:diff = system('git --no-pager diff --staged')\n  let l:prompt = \"generate a short commit message from the diff below:\\n\" . l:diff\n  let l:config = {\n  \\  \"options\": {\n  \\    \"model\": \"gpt-4o\",\n  \\    \"initial_prompt\": \"\u003e\u003e\u003e system\\nyou are a code assistant\",\n  \\    \"temperature\": 1,\n  \\  },\n  \\}\n  call vim_ai#AIRun(l:range, l:config, l:prompt)\nendfunction\ncommand! GitCommitMessage call GitCommitMessageFn()\n\n\n\" custom command that provides a code review for selected code block\nfunction! CodeReviewFn(range) range\n  let l:prompt = \"programming syntax is \" . \u0026filetype . \", review the code below\"\n  let l:config = {\n  \\  \"options\": {\n  \\    \"initial_prompt\": \"\u003e\u003e\u003e system\\nyou are a clean code expert\",\n  \\  },\n  \\}\n  exe a:firstline.\",\".a:lastline . \"call vim_ai#AIChatRun(a:range, l:config, l:prompt)\"\nendfunction\ncommand! -range -nargs=? AICodeReview \u003cline1\u003e,\u003cline2\u003ecall CodeReviewFn(\u003crange\u003e)\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to open a pull request, report an issue, or contribute to the [Community Wiki](https://github.com/madox2/vim-ai/wiki).\n\n## Important Disclaimer\n\n**Accuracy**: GPT is good at producing text and code that looks correct at first glance, but may be completely wrong. Be sure to thoroughly review, read and test all output generated by this plugin!\n\n**Privacy**: This plugin sends text to OpenAI (or other providers) when generating completions and edits. Therefore, do not use it on files containing sensitive information.\n\n## License\n\n[MIT License](https://github.com/madox2/vim-ai/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadox2%2Fvim-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmadox2%2Fvim-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmadox2%2Fvim-ai/lists"}