Page 1 of 1

Disable pre-creation of empty files for editor

Posted: 2024-02-07, 14:43 UTC
by browny
When using Shift+F4 with a new file name, TC first creates an empty file because otherwise some editors might fail with "file not found" error.
This has unpleasant side effects.
The first is that quitting editor without saving still leaves an empty file.
Second is discussed in this topic: Use UTF-8 with byte-order mark when creating a new .txt file - file encoding might be treated differently for new and already existing files, but the idea of forcing file contents and encoding is simply bad.

Maybe an option could be added, so that creation of empty file would be avoided?
There is a space in Options dialog around editor name, but this setting is not too obvious and might be restricted to .ini file only.

Re: Disable pre-creation of empty files for editor

Posted: 2024-02-07, 16:40 UTC
by Horst.Epp
browny wrote: 2024-02-07, 14:43 UTC Maybe an option could be added, so that creation of empty file would be avoided?
This would not allow creating .txt files formatted as UTF-8 with BOM as a default.
There is a need for the template file to copy over into the new file.

Re: Disable pre-creation of empty files for editor

Posted: 2024-02-07, 20:13 UTC
by tuska
2browny

When I press Shift+F4, NO file is created immediately by default.
A window appears with this text: "Enter file name to edit:"
Only after you have entered a name and confirmed with "OK" is the file created and opened in the editor.

If you are referring to cm_Edit, redefined to Shift+F4, e.g.
cm_Edit /CGL1 /T="C:\totalcmd\Templates" /N="_.txt"
then the parameter /G ... G: Go, create new files immediately (has no effect when not using C)
ensures that the file is created immediately.

If you omit the parameter /G, the window appears with the text: "Enter file name to edit:"
Only after you have entered a name and confirmed with "OK" is the file created and opened in the editor.


TC 11.03RC4 x64/x86 | Use UTF-8 with byte-order mark when creating a new .txt file (Sample solution)

Re: Disable pre-creation of empty files for editor

Posted: 2024-02-08, 00:57 UTC
by white
tuska wrote: 2024-02-07, 20:13 UTC Only after you have entered a name and confirmed with "OK" is the file created and opened in the editor.
It seems clear to me that the OP wants an option so the filename is passed to the editor without creating the file first.

Personally, I like that an empty file remains when you exit the editor. And it doesn't seem like a big deal to need to delete it if it is not wanted. Having said that, perhaps a good way to implement such feature is to implement it using the template feature. A special template filename or special content in a template file could signal to TC to not create the file beforehand.

Re: Disable pre-creation of empty files for editor

Posted: 2024-02-08, 08:47 UTC
by browny
white wrote: 2024-02-08, 00:57 UTC It seems clear
It seems clear because you do actually read, unlike those who use tunnel vision.
Nowhere UFT-8 or templates were specified in the opening message.

Editor will create new files with the configured encoding; otherwise do not use the suggested option.
tuska wrote: 2024-02-07, 20:13 UTC Only after you have entered a name and confirmed with "OK" is the file created and opened in the editor.
Incorrect. File needs to be created only if it did not exist.

Re: Disable pre-creation of empty files for editor

Posted: 2024-02-08, 10:16 UTC
by tuska
browny wrote: 2024-02-08, 08:47 UTC
tuska wrote: 2024-02-07, 20:13 UTC Only after you have entered a name and confirmed with "OK" is the file created and opened in the editor.
Incorrect. File needs to be created only if it did not exist.
I can only counter with this statement:
If I want to open an existing file, I don't need Shift+F4,
because then I would open this file with a double or single click.

Due to your statements, I unfortunately have a problem understanding this topic.
I am therefore withdrawing from this topic.