I've been told that a scientist theoretically invented the idea of a replicator, like the one used in Star Trek.
Can anyone confirm this, or cite the first use of a replicator-type technology in science fiction?
You're probably thinking of John von Neumann, and his 1966 work Theory of Self-Reproducing Automata. Self-replication machines are sometimes referred to as von Neumann machines in his honour.
And then in 1986, K. Eric Drexler published The Engines of Creation, which was the first popular account of microscopic self-replicating machines, or nanotechnology.
In one of the Tom Swift novells, started in 1910 (!!! I was shocked by that detail. The library by my cottage had 40 of the volumes, like the Hardy Boys volumes and I read them all every year) had a novel where he used a Cyclotron, and since he was accelerating things close to light speed, they were getting 'massier' therefore by pumping energy into it, he could make heavier atoms, and minus HUGE amounts of details, could make base materials out of it, from which he could then make 'things'. As a kid this was great fun to read. Additionally, I remember as I learned about this in physics classes, thinking of this example to debunk its issues.
As I recount it now, as an adult, I realize the huge suspension of disbelief required... Nonetheless a sort of example.
Upon re-reading the Wikipedia entry I see that the series I grew up with was the second series, written in the 1940-1960 range. Nonetheless I remember it fondly from my youth!
Karel Čapek's 1921 play R.U.R. (Rossum's Universal Robots)
Seems to be the first time there was talk about self replicating machines.
in 'M33 in Andromeda'(1943) by A. E. van Vogt talks about self-replicating weapons factories.
This is about the earliest I could find.
The accepted answer makes me think you're actually asking about self-replicating machines, but here's one of the earliest examples of a star trek replicator I know of:
The Man Who Awoke, a scifi novel originally published in 1933, mentioned people in the year 15,000 AD as having machines that could create any sort of material using a supply of raw ingredients (basically, put dirt and leaves in, get gold and silver out)
I don't know if this is the first appearance, but in 1945 George O. Smith published two stories in his Venus Equilateral series that dealt with replicators. In "Special Delivery", Don Channing shows that the new matter transmitter can be used as a duplicator. In "Pandora's Millions", the Venus Equilateral crew has to come up with something that can't be duplicated in order to re-establish a monetary system.
Primo Levi’s short stories about the ‘mimer’, from 1966 (English translations appeared in the 1990 collection The Sixth Day and Other Tales), are quite notable early examples, although certainly not the earliest.