This repository has been retired. For better functionality see editfile, which is much more lightweight and portable
A terminal-based text editor wrapper with built-in validation for multiple file formats. Designed for system administrators and developers who need reliable file editing with syntax checking.
- Syntax validation for multiple file formats
- Safe file editing with temporary file handling
- Automatic editor detection
- Line number targeting support
- Binary file detection and protection
- Shell script validation with shellcheck
- Code: Python, PHP, Shell scripts
- Data: JSON, YAML, XML, TOML, INI, CSV
- Markup: HTML, Markdown, SVG
# Clone the repository
git clone https://github.com/Open-Technology-Foundation/edit_file
cd edit_fileThe tool uses a virtual environment and requires Python packages and external programs for full functionality:
# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt
# Make scripts executable
chmod +x edit_file edit_file.py filetype.py shellcheckr.pySome validators require external programs:
# For Ubuntu/Debian
sudo apt install shellcheck yamllint php-cli
# For Fedora/RHEL/CentOS
sudo dnf install ShellCheck yamllint php-cli
# For macOS with Homebrew
brew install shellcheck yamllint phpThe tool works without these programs but will skip validation for those file types.
# Create a system-wide link to the launcher script
sudo ln -s $(pwd)/edit_file /usr/local/bin/edit_fileThe launcher script automatically activates the virtual environment before running the Python program.
Basic usage:
./edit_file <filename>Options:
-n, --no-validate Skip validation
-l, --line LINE Start editing at specified line number
-s, --shellcheck Run shellcheck on shell scripts
-V, --version Show version information
If installed system-wide, you can use it from any directory:
edit_file <filename>Edit Python file with validation:
./edit_file script.pyEdit YAML file starting at line 50:
./edit_file -l 50 config.yamlEdit shell script with shellcheck validation:
./edit_file -s deploy.shSkip validation when editing:
./edit_file -n data.jsonThe tool selects editors in this priority:
$EDITORenvironment variable- Available system editors: joe, nano, vim, vi, mcedit, ne, micro, emacs, jed, gedit
| File Type | Validation Method |
|---|---|
| Python | Python compiler |
| PHP | php -l |
| Shell | bash -n + shellcheck |
| JSON | json.load |
| YAML | yamllint + PyYAML |
| XML | ElementTree |
| HTML | html5lib |
| Markdown | mdformat |
| TOML | tomli/toml |
| INI | configparser |
| CSV | csv module |
- Python 3.12+
- PyYAML (for YAML validation)
- colorama (for colored output)
- html5lib (for HTML validation)
- mdformat (for Markdown validation)
- tomli (for TOML validation)
- shellcheck (for enhanced shell script validation)
- yamllint (for enhanced YAML validation)
- php-cli (for PHP validation)
edit_file.py- Main editor scriptfiletype.py- File type detectionshellcheckr.py- Shell script validation wrapperrequirements.txt- Python dependencies
Licensed under the GNU General Public License v3.0 - see the LICENSE file for details.