A lightweight, fast, terminal-based text editor library for Python. PyTEdit provides a modular and extensible framework for building terminal text editors, similar to nano or micro, but with modern Python features.
- File loading and saving
- Arrow key navigation
- Basic editing (insert, delete, backspace)
- Save & quit shortcuts (
Ctrl+S,Ctrl+Q) - Responsive interface with smooth cursor movement
- Clean, modular code structure
- Can be used as a library or standalone application
pip install pytedit# Launch editor
pytedit
# Open a file
pytedit myfile.txtfrom pytedit import Editor, TextBuffer
# Create a custom editor
class MyCustomEditor(Editor):
def __init__(self):
super().__init__()
# Add custom initialization
self.status_message = "My Custom Editor"
def create_key_bindings(self):
kb = super().create_key_bindings()
# Add custom key bindings
@kb.add('c-f')
def _(event):
self.status_message = "Find functionality (custom)"
self.refresh_screen()
return kb
# Run your custom editor
if __name__ == "__main__":
editor = MyCustomEditor()
editor.run()PyTEdit is built around these core components:
- TextBuffer: Manages text content and cursor position
- Editor: Handles input, rendering, and coordinates components
- Key Bindings: Configurable keyboard shortcuts for editor functions
- Undo/redo stack
- Syntax highlighting with Pygments
- Line numbers
- Search & replace functionality
- Configurable themes and keybindings
- Multiple file buffers
- Split-screen editing
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.