"But the Comforter, which is the Holy Ghost, whom the Father will send in my name, he shall teach you all things, and bring all things to your remembrance, whatsoever I have said unto you." (John 14:26)
John wrote his detailed discourses of Jesus (almost half of the verses in John's gospel consist of His words) approximately fifty years after Christ spoke them, yet John was able to report them verbatim because of the supernatural memory of them brought back by the Holy Spirit. The same must have been true for the other biblical writers as they recalled words and events of years before.
In a real, though different, sense, the Holy Spirit also can "bring to our remembrance" the words of Scriptures just when they are especially needed in witnessing or for personal guidance or some other need. This will only be operational, of course, if they have first been stored in our memory, either by direct memorization or by such frequent reading and studying of the Bible as to make it a part of our subconscious memory.
Recall how the unlearned fisherman Peter was able to quote long passages of Scripture when he needed them (see, for example, Acts 2:16-21, 25-28, 34-35). He had apparently spent much time in studying and even memorizing key portions of the Old Testament. Jesus, of course, frequently quoted Scripture in His conversations, and Paul quoted Scripture abundantly in his epistles. Should we not do the same?
Scripture memorization has been a great blessing to many Christians over the years but seems to have become almost a lost art in this day and age. Nevertheless, Christ has promised answered prayer: "If ye abide in me, and my words abide in you" (John 15:7). So, as Paul urged, "Let the word of Christ dwell in you richly" (Colossians 3:16). HMM