I want to rename my current tab to something other than "New1" but not save This is so that when i open a tab with my script, the tab would have a better describing name. I work with log files and open parts of log with formatting scripts.
I can rename tab in notepad++ by right clicking tab and rename.
Is there a possibility to do the same with python scripts something like notepad.setTabTitle("My_new_name")
My quite simple script looks like this: selects the line cursor is at, copies it and pastes the copied line to a new tab, formats that text
myline = editor.getCurLine()
editor.copyText(myline)
notepad.new() #rename here or after this line
editor.paste()
editor.selectAll()
notepad.runPluginCommand("MIME Tools", "Base64 decode")
notepad.runPluginCommand("XML Tools", "Pretty print")
I want to rename my current tab to something other than "New1" but not save This is so that when i open a tab with my script, the tab would have a better describing name. I work with log files and open parts of log with formatting scripts.
I can rename tab in notepad++ by right clicking tab and rename.
Is there a possibility to do the same with python scripts something like notepad.setTabTitle("My_new_name")
My quite simple script looks like this: selects the line cursor is at, copies it and pastes the copied line to a new tab, formats that text
myline = editor.getCurLine()
editor.copyText(myline)
notepad.new() #rename here or after this line
editor.paste()
editor.selectAll()
notepad.runPluginCommand("MIME Tools", "Base64 decode")
notepad.runPluginCommand("XML Tools", "Pretty print")
Share
Improve this question
edited Mar 27 at 8:00
user20477151
asked Mar 27 at 7:50
user20477151user20477151
11 bronze badge
0
1 Answer
Reset to default 0The following python code will use notepad++ to open an existing file in the current folder and make the tab name equal to the name of the file opened:
import os
import subprocess
notepad_plus_plus = r"C:\Program Files\Notepad++\notepad++.exe"
file_name = "test.txt"
if os.path.exists(file_name):
subprocess.run([notepad_plus_plus, file_name])
else:
print("File not found")