Hi, How, can i insert the default text into the file?
Please expand on what you want, including examples if possible.
Things you need to clarify:
- when do you want the default text inserted? (before save, on opening, on use of a hotkey, etc)
- do you want it inserted into all documents or just some?
- do you need to do this to a bunch of existing documents? (in which case a find/replace might be appropriate)
- Where in the document does the text need to be inserted (beginning, after a certain line, end)?
Off the top of my head, an easy way to do this is probably just to use the macro recorder to record typing out this text, stop recording the macro, and then save it to a hotkey.
IMPORTANT NOTE: if you copy the test and record a macro of pasting it in, the macro created will just paste whatever is in the clipboard, rather than pasting the text that you copied when you recorded it.
Notepad++ doesn’t have a “default document template” which is used whenever you create a new file.
You could use the Windows OS “create new XXXX file” which allows a template, then create the file through the OS, then edit the resulting new file from Notepad++. (To implement, you would have to search the interweb to find out how to define the new-file template for a specific filetype or extension for your version of Windows; this Forum is not a generic Windows help forum, so we aren’t the right place for more details on that.)
But there are plugins for Notepad++ which do similar things: I don’t know of any that use “new document templates” (though there might be ones). But there are some which allow entering snippets (Snippets plugin) or other quick text (QuickText plugin, which is what I use), which allow entering chunks of text using triggers. In the programming languages I use, I have a “start” trigger, where I type
startthen hit the plugin’s keystroke, and it converts that into my default text for the filetype. (For each language, I have a macro that I recorded to create a new file and then change the Language to that programming language. Then i type
startand the keystroke, get my template, and immediate Save to disk.)
You could use the Windows OS “create new XXXX file” which allows a template
As far as I know, there is no such thing as default templates for files baked into Windows. Many applications, including Notepad++ allow for defining the default style but I don’t know of any that allow for automatically filling in the file content with a blank document template.
As @Mark-Olson suggested, we need more information but most likely the issue will be addressed via scripting.
As far as I know, there is no such thing as default templates for files baked into Windows.
According to Microsoft, it is possible to specify templates for creating new files, though I’ve never tried it:
Thank you @Coises
I looked at my machine and was able to see how the various “new” for various file types were done except for “Text Document”. A new Text Document works and creates a zero length “New Text Document.txt” file but I could not see how it was done meaning I could not then adjust that to use the
FileNamemechanisms for a template. It’s strange as I searched my registry for things such as “Text Document” (including the UTF-16 encoded versions), and “NullFile.” Everything I found made sense and was for the other things can be newly created.
Thus, in terms of answering the OP I suspect scripting plus needing more details from the OP.
@mkupper Make the change in HKCR\.txt\ShellNew; e.g., delete NullFile and add FileName with a value that gives the full path and name of the file you want to use to initialize new documents.
The file name “New Text Document.txt” appears to come from the ItemName key. On my system, the value of that key makes a reference to notepad.exe — presumably to a string resource inside the program that is nationalized. If you remove that key, the new file name is “New Notepad++ Document.txt”. Other appearances of “Text Document” in the registry appear to have nothing to do with this, and at least one is connected to something other than a plain text file.
Thank you. The puzzle for me is that I don’t have a
HKCR\.txt\ShellNewkey. Granted, I can create one.
However, I was trying to figure out is how and why “Text document” is available in Windows explorer’s “New” button list and right click list. I have 11 choices available for “New.” For ten of them I saw the ShellNew subkey and the values used to create new files. Those all made sense to me. The missing or invisible key of the 11 was whatever mechanism is used for new “Text document”.
I ran a profiler on explorer.exe and see that it’s building the New list out of a cache and that it pulled the information related to “Text Document” out of the resources for Notepad.exe
ms-resource://Microsoft.WindowsNotepad/Resources/ShellNewDisplayName_Txt. I’m guessing that because I left the Windows 11 Notepad.exe store app installed that it tells Windows Explorer to add itself to the new list.