TL;DR
I use for programming emacs through spacemacs. For searching and refactoring I use grep and sed, powerful and fast utilities, but complex and with steep learning curve. This post gives sed command that I use for refactoring Python package paths that contain dot character.
The Problem
The problem with dot is that is used in regular expressions as special instructor character. It means “any single character could be in this position”. When you move in Python class or method in different folder, for Python this is new package path. So in all files where you use this class or method, you need to refactor import statement. Import contains dots to denote subfolder structure.
Solution
To automate this task, I use following sed command to change imports
from tentamen/tests/models => from tentamen/tests/database/local/models
Options breakdown:
-i means edit files in place -- this will be added in front of original file name as backup of original file s this is replace text sed command, in first // is original text, in second // is new text g means replace all occurrences of old text in file. *.py is file filter, in this case for Python files. dot is escaped with backslash. This instructs sed to not use dot as instructor character.
Conclusion
sed and grep are powerful testing tools. Do not be afraid to learn how to use them.