Web browsers have great feature: when CTRL+W in single tabbed window is pressed, it closes the window. I also think it does not make sense to actualy execute "close & new" command in npp+ with CTRL+W in single tabbed window, which happens now if only one tab is opened.
I use mouse hotkey binding to either close tabs or exit program with mouse button. The problem is, with mouse hotkey binding software I cannot detect if there is only one tab open in tabbed interface to switch key to ALT+F4 to close window. So I have to chose between CTRL+W or ALT+F4, instead to merge both features in CTRL+W hotkey, which would also close np++ window if there is only single file opened.
Please either implement this feature or provide at least option to close application in case CTRL+W is pressed when only one tab is opened. Thanks.
install PythonScript plugin (from Plugin manager), create a new scipt, copy/paste below code in it. You can create button on toolbar or assign a shortcut to execute this script, I guess you should use CTRL+W.
if len(notepad.getFiles()) > 1:
It does not work. If I use sys.exit() instead of menuCommand, then notepad++ hangs itself.
code works for me without issues.
Can you describe what goes wrong for you?
If I use your code, then notepad++ does not exit when there is only single tab opened.
If I change the line
then np++ hangs when script is executed when only one tab opened.
I have version 6.6.6. And you?
Any feedback? I am willing to donate for this feature.
thanks for the remainder, I am using a custom version which is based on some older version. I just downloaded latest 6.6.7 ZIP version, tried there and indeed it doesn't work. It closes a file, but not the application.
I will check what is going on and post an updated version during the day.
As for donation, here is my offer: if I provide a working script, you pay any amount to either:
a) Linux Mint project: http://linuxmint.com/donors.php
b) Krita fundraiser: https://www.kickstarter.com/projects/krita/krita-open-source-digital-painting-accelerate-deve
it looks like new version is reporting invisible buffers, here is a modified script that takes into account these buffers:
files = notepad.getFiles()
console.write("files: " + str(notepad.getFiles()) + "\n")
console.write("view: " + str(notepad.getCurrentView()) + "\n")
if len(files) == 1:
elif len(files) == 2 and \
files.startswith("new ") and files == 0 and files == 0 and \
files.startswith("new ") and files == 0 and files == 1:
Can you test this and provide feedback here?
It works. I simplified it to:
if len(notepad.getFiles()) <= 2:
However, I hoped that somebody would get this integrated in np++ binary, without the need to use plugin and possibly update the script later when design of np++ changes.
Nevertheless, I will donate. Thanks.
your version will work with just one view active, but you might have a legit case where two files are open in different views. If such scenario is not important to you, your version will work just fine.
Anyway, I agree that this might be an interesting option to include in main application.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.