This repository has been archived by the owner. It is now read-only.
Replace text in files
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
pics
test
.gitignore
CHANGELOG.rst
COPYING
MANIFEST.in
README.rst
replacer.py
setup.py
test_requirements.txt

README.rst

NOTICE

This project is no longer maintained. Users are encouraged to switch to Ruplacer, a rewrite in Rust by the same author. It is both faster and more featureful, and I believe you'll like it :)

replacer

http://img.shields.io/pypi/v/replacer.png

Replace text in files.

Requirements

Python 3.

Install

Install with pip as usual.

Or, use the AUR on Arch Linux.

Screenshot

pics/screenshot.png

Basic usage

replacer [OPTIONS] PATTERN REPLACEMENT [FILES ...]

Note that internally, we'll call Python with:

re.sub(<PATTERN>, <REPLACEMENT>, line)

for each line of every regular file found in the current working directory.

This means you can use fancy backward references with \1

  • By default hidden files, and files matching build-*, .git, .svn, *.py[co], *.[oa] , *.back, *~ , *.so, *.a will be ignored

  • If FILES is given, replacement will be performed on the files given as argument.

  • You can also specify --file-filter to specify a pattern to match against the filenames. For instance, to replace in every .c file, use:

    replacer spam eggs --file-filter '*.c'
    
  • You can create a backup for each modified file by using --backup

Advanced usage

See

replacer --help

for a full list of options

History

First version was implemented in Bash in ctafconf.

Then it was rewritten in Python in this commit.