How can I edit multiple text files as one virtual document?
Solution 1:
As I discussed on Root Access, the broad class of tool you're looking at is an outline text editor. Outline editors let you work in blocks of texts, treat them as discrete units, and link them together, perfect for your use case.
As far as ANYONE I have talked to who needs/has used one has told me, literature and latte's scrivener is the program to beat, though this answer on Ask Ubuntu suggests a few alternatives.
Solution 2:
If you're willing to consider a bit more than plain-text, then this is very possible. Two such ways are using Markdown (which doesn't have native include support, but several document processors do) or LaTeX.
Markdown
With minimal markup, the Pandoc route may be what you want, since your text fragments just need to be written as Markdown documents (which, without using any additional features, are still just plain-text documents; this is the formatting system used here on Super User and the other Stack Exchange websites). Inspired by this SO question, let's say the text fragments are in the current working directory:
01_introduction.md
02_examples.md
03_discussion.md
04_conclusion.md
These can be merged & rendered as a single file with Pandoc using the command:
pandoc *.md > merged.html
Pandoc is also compatible with the LaTeX format which may also serve your needs, although there are indeed several other LaTeX document editors/compilers which might be better suited to the task.
LaTeX
Consider creating a rather simple LaTeX document, and place your plain-text files into several other files. You can then use the LaTeX \input{filename}
command (or \include
if you need that functionality) in the parent document to join and render all of the individual text fragments as a singular document.
So, you might want to create a parent .tex document to wrap all of your sub-.tex files (which just contain plain-text; LaTeX's \include
works similar to that of the C/C++ programming languages). So let's say you have the same Markdown files as before, but renamed from .md
to .tex
(e.g. now you have 01_introduction.tex
, 02_examples.tex
, ...).
You can then make another file to compile (e.g. 00_parent.tex
), which just contains the following (see this article for more advanced ways to set up a LaTeX document):
\documentclass{minimal}
\begin{document}
\input{01_introduction.tex}
\input{02_examples.tex}
\input{03_discussion.tex}
\input{04_conclusion.tex}
\end{document}
You can then compile the 00_parent.tex
file with your favourite LaTeX editor (like TeXWorks) or just compile it from a terminal using the native LaTeX tools or any others you might like (Pandoc also seems to support LateX).