@AcmeNuclear said in How to Insert/Import Text from a Separate File:
Does Notepad++ have an easier way to make this text file insertion into the current file - without executing something similar to Open (source file), Select all (source file); Copy; Select target location (receiving file); Paste; Close (source file)?
Not really.
But if you’re willing to use a scripting plugin, a simple script can be written:
from Npp import *
import os
f = notepad.prompt('Enter file name:', '', '')
if f and os.path.isfile(f):
notepad.open(f)
editor.selectAll()
editor.copy()
notepad.close()
editor.paste()
The script assumes you have the “MRU” setting selected (otherwise when the script closes the file tab it opens, you won’t be returned to the correct file tab):
de7fbf65-50c8-42ec-bed9-ec4e218fe5ed-image.png
And, yes, this script is very simple. It intentionally loads the file into Notepad++ (instead of just reading the file with Python) to avoid making non-Notepad++ assumptions about the encoding of the file, it expects you to know the name of the file you want (instead of a “picker”), it will close the to-be-inserted-file if that file happens to be open in N++ when the script is run, etc.). Many things could be done to make the script more well-rounded.
For the basics of scripting, see HERE.