AI-enhanced Vim-like text editor with code assistance and generation
Reason this release was yanked:
not working. incomplete MANIFEST.in
Project description
AIVim - AI-Enhanced Text Editor
AIVim is an AI-enhanced version of Vim built in Python, offering intelligent code assistance and generation capabilities while maintaining the core modal editing experience. Combining the power of different AI models with familiar Vim interactions, AIVim helps developers understand, improve, and generate code more efficiently.
Features
Modal Editing
- Normal Mode: Navigate and edit text using Vim-style commands
- Insert Mode: Type and modify text directly
- Visual Mode: Select text for operations
- Command Mode: Enter commands with the
:prefix
AI-Powered Assistance
- Code Explanation: Understand complex code with detailed explanations
- Code Improvement: Get AI-powered refactoring and optimization suggestions with diff-style presentation
- Code Generation: Generate new code based on natural language descriptions
- Custom AI Queries: Ask questions about your code and receive contextual answers
- Code Analysis: Get complexity analysis and bug detection for your code
- Multi-Provider Support: Choose between OpenAI, Anthropic Claude, or local LLM models
Editor Features
- Vim-Style Commands: Familiar commands like
dd(delete line),yy(yank line),p(paste) - Multi-Tab Interface: View and compare original and AI-improved code in tabs
- Version History: Automatic tracking of file changes with metadata
- File Backups: Automatic backup creation when applying improvements (with timestamps)
- Loading Indicators: Visual feedback when AI operations are in progress
- Line Numbers: Display line numbers for easier navigation and reference
- Status Line: Displays current mode, filename, cursor position, and tab information
- Syntax Highlighting: Basic syntax highlighting for improved code readability
- Animated Loading: Visual indicators during AI operations to show progress
Web Interface
- Browser Access: Access AIVim from a web browser via Flask
- Code Editor: Edit and modify code directly in the browser
- AI Operations: Access all AI capabilities through the web interface
- Results Display: View AI-generated output in a dedicated results area
AI Commands
AIVim provides the following AI-specific commands:
| Command | Description |
|---|---|
:explain <start> <end> |
Get an explanation of lines start through end |
:improve <start> <end> |
Get improvement suggestions for lines start through end |
:generate <line> <description> |
Generate code at line based on the description |
:analyze <start> <end> |
Analyze code complexity and detect bugs in lines start through end |
:ai <query> |
Ask a custom question about the current file |
:set model=<provider> |
Set the AI model provider (openai, claude, local) |
Tab Navigation Commands
| Command | Description |
|---|---|
:nexttab or :n |
Switch to the next tab |
:prevtab or :N |
Switch to the previous tab |
:tabnew |
Create a new empty tab |
:tabnew <filename> |
Create a new tab and open the specified file |
:tabclose |
Close the current tab |
Vim Commands Supported
| Command | Description |
|---|---|
dd |
Delete current line |
yy |
Yank (copy) current line |
p |
Paste after cursor |
P |
Paste before cursor |
o |
Open new line below cursor and enter insert mode |
O |
Open new line above cursor and enter insert mode |
x |
Delete character under cursor |
u |
Undo last change |
Ctrl+r |
Redo |
i |
Enter insert mode |
v |
Enter visual mode |
gg |
Go to first line |
G |
Go to last line |
$ |
Go to end of line |
/pattern |
Search forward for pattern |
?pattern |
Search backward for pattern |
n |
Find next search match |
N |
Find previous search match |
:%s/old/new/g |
Replace all occurrences of 'old' with 'new' |
:<line_number> |
Jump to line number (integer expected) |
:$ |
Jump to last line of the file |
Usage
Basic Editing
- Press
ito enter insert mode,ESCto return to normal mode - Use
:wto save,:qto quit,:wqto save and quit - Navigation works with arrow keys (primary) or
h,j,k,lkeys (alternative) - Jump to specific lines with
:1,:14or:$(last line) - Search for text with
/pattern(forward) or?pattern(backward) - Use
nto find next match,Nto find previous match - Replace text with
:%s/old/new/gsyntax
AI Features
- Navigate to the code you want to work with
- In normal mode, type
:explain 10 20to explain lines 10-20 - Use
:improve 10 20to get improvement suggestions:- A new tab opens showing a colorized diff view of proposed changes
- Review the modifications in the diff view
- To apply the changes, switch back to the original tab and confirm
- A backup of the original file is automatically created with a timestamp
- Generate code with
:generate 5 "Create a function that calculates factorial" - Analyze code with
:analyze 10 20to identify complexity issues and potential bugs - Ask questions with
:ai How does this algorithm work? - Switch between AI providers with
:set model=openai,:set model=claude, or:set model=local
Installation
To install AIVim:
# Install from source
git clone https://github.com/yourusername/aivim.git
cd aivim
pip install -e .
# Run AIVim
python -m aivim.run_editor file.py
System-wide Installation
To make AIVim available as a system-wide command (aivim), follow these steps:
# For temporary use in current session
alias aivim='python -m aivim.run_editor'
# For permanent installation, add to your shell configuration
echo 'alias aivim="python -m aivim.run_editor"' >> ~/.bashrc
# Or for Zsh
echo 'alias aivim="python -m aivim.run_editor"' >> ~/.zshrc
# Apply changes without restarting the terminal
source ~/.bashrc # or source ~/.zshrc
For a more robust system-wide installation, create a symbolic link:
# Create a symbolic link in a directory that's in your PATH
sudo ln -s "$(which python) $(pwd)/run_editor.py" /usr/local/bin/aivim
sudo chmod +x /usr/local/bin/aivim
# Now you can run AIVim from anywhere
aivim myfile.py
Configuration File
Instead of setting environment variables, you can create a configuration file for storing API keys:
# Create a config directory
mkdir -p ~/.config/aivim
# Create and edit the configuration file
cat > ~/.config/aivim/config.ini << EOF
[api_keys]
openai = your_openai_api_key_here
anthropic = your_anthropic_api_key_here
llama_model_path = /path/to/your/local/model.gguf
[settings]
default_model = openai
EOF
# Set proper permissions to protect your API keys
chmod 600 ~/.config/aivim/config.ini
AIVim will automatically check for this configuration file and use these settings in addition to any environment variables that are set.
Setting Up Local LLM Support
AIVim supports using local LLM models via llama-cpp-python:
# Install the local LLM package
pip install llama-cpp-python
# Download a small model using the provided script
python download_local_model.py --model tinyllama
# Or list available models
python download_local_model.py --list
# Once downloaded, you can use it by setting the model:
# Inside AIVim: :set model=local
The download_local_model.py script supports several small models suitable for local execution:
| Model | Size | Description |
|---|---|---|
| tinyllama | ~1GB | Small but capable model for code assistance |
| phi2 | ~1.7GB | Microsoft compact yet powerful model |
| stablelm | ~1.5GB | Stability AI efficient language model |
Web Interface
AIVim also includes a web interface for easy access:
# Start the web server
python main.py
# Access AIVim in your browser at:
# http://0.0.0.0:5000
The web interface provides access to all the AI-powered features through a more traditional web IDE experience. It communicates with the same AI services backend as the terminal-based editor.
Embedding AIVim
AIVim can be embedded into other Python applications:
from aivim import embed_editor
# Open a file in the embedded editor
embed_editor("path/to/file.py")
# Or create a new file
embed_editor()
Requirements
- Python 3.8 or higher
- OpenAI API key (set as OPENAI_API_KEY environment variable)
- Optional: Anthropic API key (set as ANTHROPIC_API_KEY environment variable)
- Optional: Local LLM model (set model path as LLAMA_MODEL_PATH environment variable)
- curses library (included with Python on most systems)
License
This project is licensed under the MIT License - see the LICENSE file for details.
Publishing to PyPI
AIVim can be published to PyPI using the GitHub Actions workflow. For detailed instructions, see docs/publishing.md.
# Install from PyPI (once published)
pip install aivim
# Run the editor
aivim myfile.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aivim-0.1.0.tar.gz.
File metadata
- Download URL: aivim-0.1.0.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e6ad6643d9be1362510343f7f425d714efba418d57dac240aaa59a50454fb9f
|
|
| MD5 |
266c06baabf4aea7699f46db61523c40
|
|
| BLAKE2b-256 |
acae5b9ebc4729c09671b6e614bb9e1c35961794708094764850240cd2084eec
|
File details
Details for the file aivim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aivim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2902939fc602079ddf27d5facb86646f5df586538aba2dc747291441512b3601
|
|
| MD5 |
6f49e107602e165eeb1e8370b33a4f04
|
|
| BLAKE2b-256 |
e3cddabee02078ff25626258379e582e71c9122f0c85fa6902de44ff0845d6ef
|