Search code examples
filenotepad++

Combining files in Notepad++


Is there a Notepad++ plugin out there that automatically combines all currently opened files into a single file?

Update: Yes, I am very aware of copy and paste :) I'm working with lots of files, and I want a solution that makes this step in the process a little bit faster than several dozen copy and pastes.

I'm aware of utilities for combining files, but I want the convenience of combining specifically the files that are currently opened in my text editor.

If there isn't a plugin out there already, I'll write one myself; I was just wondering if it exists already to save me the time of developing one.


Solution

  • I installed the Python Script plugin and wrote a simple script:

    console.show()
    console.clear()
    files = notepad.getFiles()
    notepad.new()
    newfile = notepad.getCurrentFilename()
    for i in range(len(files) - 1):
        console.write("Copying text from %s\n" % files[i][0])
        notepad.activateFile(files[i][0])
        text = editor.getText()
        notepad.activateFile(newfile)
        editor.appendText(text)
        editor.appendText("\n")
    console.write("Combine Files operation complete.")
    

    It looks at all the files currently opened in Notepad++ and adds them to a new file. Does exactly what I need.