Replace [[Word]] with a word from another file
Notepad++ can be used for everything from writing down random notes to advanced text manipulation. But as mentioned in comments you need to install Python Script plugin from Plugin Manager.
Copy the file with your substitutions to e.g. D:/_working/paired-search-replace.txt and separate values with space or as you did =
:
Apple=Apfel
Banana=Banane
Cherry=Kirsche
Train=Zug
satellite antenna=Satellitenantenne
Create a new script.
import re
separators = "=", "\n"
def custom_split(sepr_list, str_to_split):
# create regular expression dynamically
regular_exp = '|'.join(map(re.escape, sepr_list))
return re.split(regular_exp, str_to_split)
with open('D:/_working/paired-search-replace.txt') as f:
for l in f:
s = custom_split(separators, l)
editor.replace(s[0], s[1])
Run the new script against the text you need to work on and substitute.
Edit:
To include the opening and closing square brackets for your special case, the following addition can be made in the script:
with open("D:/_working/paired-search-replace.txt") as f:
for l in f:
s = custom_split(separators, l)
s[0] = "[[" + s[0] + "]]"
s[1] = "[[" + s[1] + "]]"
editor.replace(s[0], s[1])
For a small translation list only:
If you don't want to use a script as mentioned by others you need to do some special steps using Notepad++. Please note, this is limited by search and replace string length.
Copy the paired translation list to two files e.g. search-source.txt
and replace-target.txt
(for working with) and edit the content and format to search and replace strings as shown below.
You can use Notepad++'s RegEx feature and the "Column Editor" mode for this. E.g. select the column you want by holding Alt and dragging down the column. Then go to "Edit -> Column Editor". Choose the "Number to Insert" button, then choose the starting value and the increment. It will replace the column with the values you want. Use STRG+J later to join the lines
Then try a regular expression replace of
(Apple)|(Banana)|(Cherry)|(Train)
with
(?1Apfel)(?2Banane)(?3Kirsche)(?4Zug)