Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyEdit is a terminal-based AI powered text editor inspired by Vim, implemented in Python.

License

NotificationsYou must be signed in to change notification settings

THAMIZH-ARASU/PyEdit-A-Vim-like-Terminal-Text-Editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyEdit is a terminal-based text editor inspired by Vim, implemented in Python. It provides a modal editing experience, file explorer with live preview, search, undo/redo, and more—all within your terminal. PyEdit is designed for speed, efficiency, and extensibility, making it a great choice for developers who love working in the terminal.


sample_output

Features

  • Modal Editing: Normal, Insert, Visual, Command, Search, and File Explorer modes.
  • Vim-like Keybindings: Familiar navigation and editing keys (h/j/k/l,i,v,:,/, etc.).
  • File Explorer Sidebar: Browse and open files and directories, with a live preview pane that resizes with your terminal.
  • Search: Powerful in-buffer and file search with regex support.
  • Undo/Redo: Full undo/redo support for editing operations.
  • Status Bar: Displays mode, file name, modification status, and cursor position.
  • Command Mode: Save, quit, open files, and more with:commands.
  • Visual Mode: Select, copy, and delete text visually.
  • AI Autocomplete: (Optional) Press Tab in insert mode for AI-powered code suggestions (requires configuration).
  • Multi-Model AI Support: Switch between different AI models (Groq, Gemini) for code completion and AI tools.
  • AI Tools: Use:ai <action> commands for code refactoring, documentation, explanation, translation, code generation, and more (see below).
  • Lightweight & Fast: Minimal dependencies, runs in any terminal with Python and curses.

Installation

Requirements

  • Python 3.7+
  • Unix-like terminal (Linux, macOS, or Windows with WSL/compatible terminal)
  • Pythoncurses module (pre-installed on most Unix systems; for Windows, installwindows-curses via pip)

Setup

  1. Clone the repository:
    git clone<repo-url>cd neovim_clone
  2. (Windows only) Install curses:
    pip install windows-curses

Usage

Run the editor from your terminal:

python py_edit.py [filename]
  • If[filename] is provided, it will open or create that file.
  • If not, a new buffer is opened.

Keybindings & Modes

Modes

  • NORMAL: Navigation, commands (default)
  • INSERT: Text input (pressi)
  • VISUAL: Select text (pressv)
  • COMMAND: Type :commands (press:)
  • SEARCH: Search text (press/)
  • FILE EXPLORER: File browser (presse or:explorer)

Normal Mode Keys

KeyAction
h/j/k/lMove left/down/up/right
iEnter insert mode
vEnter visual mode
:Enter command mode
/Enter search mode
eOpen file explorer
xDelete character
o / OInsert line below/above
uUndo
Ctrl+RRedo
qQuit

Insert Mode

KeyAction
ESCReturn to normal mode
EnterNew line
BackspaceDelete
TabAI autocomplete (if enabled)

Visual Mode

KeyAction
dDelete selection
yCopy selection
ESCReturn to normal mode

Command Mode (`:`)

CommandAction
wSave file
wqSave and quit
qQuit
e <file>Open file
w <file>Save as file
explorerToggle file explorer
helpShow help manual

Search Mode (/)

  • Type pattern, Enter to search, ESC to cancel

File Explorer (Ranger/Yazi-Style)

The file explorer is a two-pane sidebar:

  • Left pane: Shows the directory stack and contents. Navigate with your keyboard.
  • Right pane: Instantly previews the selected file (up to the full width of your terminal).
  • Toggle the explorer:
    • Presse in normal mode
    • Or type:explorer in command mode (works from any mode)

Explorer Navigation Keys

KeyAction
j / DownMove down
k / UpMove up
l / Right / EnterEnter directory or open file
h / Left / BackspaceGo up to parent directory
rRefresh file list
q / ESCExit file explorer
  • When you select a file and press Enter/l/right, it opens in the editor and exits explorer mode.
  • When you select a directory and press Enter/l/right, it enters that directory.
  • You can also use:explorer at any time to open the explorer.

AI Model Configuration

PyEdit supports multiple AI models for code completion and AI tools. You can switch between different models based on your preferences and API availability.

Supported Models

  • Groq: Fast, reliable AI model using Llama3-70B (requiresGROQ_API_KEY)
  • Gemini: Google's latest Gemini 2.0 Flash model (requiresGEMINI_API_KEY)

Setup

  1. Get API Keys:

  2. Configure Environment:Create a.env file in the project root:

    GROQ_API_KEY=your_groq_api_key_hereGEMINI_API_KEY=your_gemini_api_key_here
  3. Model Management:

    • View current model::ai model
    • Switch models::ai model groq or:ai model gemini
    • View available models::ai models
    • Get detailed info::ai info

Model Switching

The current AI model is displayed in the status bar. You can switch between models at any time:

:ai model groq# Switch to Groq:ai model gemini# Switch to Gemini:ai models# Show available models:ai info# Show detailed model information

Your model preference is automatically saved and will be restored when you restart PyEdit.


AI Tools

PyEdit features a suite of AI-powered tools accessible via the command mode. These tools leverage the currently selected AI model to help you write, understand, and manage code more efficiently.

Usage

Type:ai <action> [args] in command mode. Example:

:ai refactor:ai doc:ai explain:ai testgen:ai review:ai nl2code create a function that sorts a list:ai translate javascript:ai search file I/O:ai commitmsg:ai chat How do I use decorators in Python?:ai snippet HTTP GET request in Python

AI Actions Explained

  • refactor: Refactors the current buffer for readability and efficiency. The buffer is replaced with the improved code.
  • doc: Generates a docstring or inline comments for the code in the buffer. The result is shown in a popup.
  • explain: Explains what the code in the buffer does in plain English. The explanation is shown in a popup.
  • testgen: Generates a unit test (e.g., pytest) for the code in the buffer. The buffer is replaced with the generated test code.
  • review: Reviews the code in the buffer and suggests improvements or points out bugs. The review is shown in a popup.
  • nl2code: Converts a natural language instruction into code (e.g.,:ai nl2code create a function that sorts a list). The buffer is replaced with the generated code.
  • translate: Translates the code in the buffer to another language (e.g.,:ai translate javascript). The buffer is replaced with the translated code.
  • search: Performs a semantic search across all Python files in the project for code related to the query (e.g.,:ai search file I/O). The results are shown in a popup.
  • commitmsg: Generates a concise git commit message for the current buffer's content. The message is shown in a popup.
  • chat: Opens a chat with the AI for general programming questions or advice. The response is shown in a popup.
  • snippet: Generates a code snippet based on a description (e.g.,:ai snippet HTTP GET request in Python). The buffer is replaced with the generated snippet.

Buffer-updating actions

  • refactor,nl2code,translate,snippet,testgen will automatically replace the buffer with the AI's code output.

Popup actions

  • doc,explain,review,search,commitmsg,chat will always show their result in a scrollable popup window, even for short responses.

Screenshots

sample_output

sample_output

sample_output

sample_output


Contribution

Contributions are welcome! Please open issues or submit pull requests for bug fixes, new features, or improvements.


Credits

  • Inspired by Vim and other modal editors.

License

This project is licensed under the MIT License.

About

PyEdit is a terminal-based AI powered text editor inspired by Vim, implemented in Python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp