Print b + str(i) + c + variable_to_replace + d + variable_to_replace + e + str(i) + f Variable_to_replace.append(notepad.prompt(notepad, replacement_title)) Replacement_title.append(str("Replacement Item ") + str(i+1)) Number_of_replacements=int(notepad.prompt(notepad, 'Number of Replacements'))Ī = "pattern_string = """ + '"' + '""' + pattern_string + '""' + '"'Ĭ = """=notepad.prompt(notepad, 'Replace', "Replaces: """įor i in range (0, number_of_replacements): Pattern_string=notepad.prompt(notepad, 'Pattern String') Run this script, and save the file in your c:/program files/Notepad++/plugins/config/PythonScript/scripts directory : #imports The below code will make it so that your Notepad++ will create its own scripts. I would really like to know how to make that possible. Interestingly, you can use this script to duplicate itself for different patterns. In your drop-down menu, go to Settings -> Shortcut Mapper. If it works, you can put it to action in the file you're working on.įor convenience, I made ctrl-shift-e a shortcut key for the Run Previous Script (#yourscriptname.py) command. Go to Plugins->PythonScript->Run Last Script. Now, create a new file ctrl-n and test the script. User_replacement_string=notepad.prompt(notepad, 'Replace', "")Įditor.replace("varr", user_replacement_string)Įditor.replace("Varr", user_replacement_string) #*** therefore, I use two replacement operations *** #*** I am using a case-sensitive replacement *** Basically, it allows the user to macro pasting a value in and then easily replace multiple variables within the pasted content.Ĭopy and paste this code, then edit it: #*** IMPORTS *** All you have to do is create a pattern string with variable names that you can remember embedded into it and save the resulting macro files in the right directory. User_replacement_string=Notepad.prompt(my_prompt) //RuntimeError: This class cannot be instantiated from PythonĮditor.replace("varr", user_replacement_string) //untestedĪlso, I want a general form that generates scripts like this, similarly to how a macro generator generates macro. Does anyone know how to do this? Especially interested in finding a variable/input option. It should go something like: "Paste text->ask for input->replace variable in pasted text with input value". I'm trying to make a macro with an 'input' pop-up dialog that synergizes with the replace feature.
0 Comments
Leave a Reply. |