Is it possible to repeat a replacement string in Notepad++?
I would like to replace matches in Notepad++ using the Find and Replace window with n repeats of a certain character. Is there any "repeat" or "multiply" syntax to enter a character n times?
Example:
Find: \s\s+
Replace: repeat("\r", 100) # replace it with 100 carriage returns
You can run a python script within the PythonScript plugin.
If it is not yet installed, follow this guide
This will replace 2 or more spaces with 100 carriage return, as explained in your question.
- Create a script (Plugins >> PythonScript >> New Script)
- Copy this code and save the file (for example format.py):
import re
def format(match):
return 100 * "\r"
editor.rereplace('\s\s+', format)
- Open the file you want to modify
- Run the script (Plugins >> PythonScript >> Scripts >> format)
- Done