ComdTeX

Documentos largos

El caso: vas escribiendo una asignatura clase a clase sobre el mismo .md, y a los dos meses tiene 3000 líneas. Estas son las herramientas para que siga siendo manejable.

Plegado por encabezados y bloques

Cada encabezado se pliega desde su línea hasta justo antes del siguiente encabezado del mismo nivel o superior. Plegar ## Clase 3 esconde esa clase y nada más. Se usa desde la flecha del margen izquierdo, o con los atajos de Monaco:

AtajoAcción
Ctrl+Shift+[Plegar la sección del cursor
Ctrl+Shift+]Desplegar
Ctrl+K Ctrl+0Plegar todo
Ctrl+K Ctrl+JDesplegar todo

Los encabezados dentro de bloques de código se ignoran: un # comentario en un script de shell no es una sección.

El plegado se recuerda por archivo, junto con el cursor y el scroll. Cambias de pestaña y vuelves, y todo sigue como lo dejaste.

Los bloques :::excalidraw se pliegan solos la primera vez que abres un archivo, porque su escena es una única línea de base64 que ocupa media pantalla. Se puede desactivar en Configuración → Editor.

Dividir el archivo cuando ya pesa demasiado

Ctrl+P → "Dividir documento en secciones (##)" corta el documento por sus ## y crea un archivo por sección junto al original. El original se queda con su preámbulo (frontmatter, introducción) y una lista de transclusiones:

---
title: Álgebra II
---

![[algebra-clase-1]]

![[algebra-clase-2]]

![[algebra-clase-3]]

La vista previa no cambia: las transclusiones incluyen el contenido, así que el documento renderizado es el mismo de antes. Lo que ganas es que cada clase es un archivo independiente, enlazable con [[…]] y buscable por separado.

Salvaguardas:

  • Pide confirmación antes de tocar nada.
  • Si alguno de los nombres destino ya existe, no divide nada y te avisa. No sobrescribe.
  • Nada se pierde: el preámbulo más las secciones reconstruyen el original.

Transclusión

Embebe contenido de otra nota sin copiarlo, con tres granularidades:

SintaxisQué incluye
![[nota]]La nota entera
![[nota#encabezado]]Solo esa sección
![[nota#^id]]Solo el bloque marcado con ese ^id

El contenido se sincroniza con el original: editas la nota fuente y la transclusión se actualiza sola en la próxima vista previa.

El outline como índice

El panel Vistas → Esquema lista los encabezados y tiene filtro: escribe “clase 7” y saltas directo. Con el filtro activo se desactiva el arrastrar para reordenar, porque reordenar una lista filtrada movería secciones que no ves. Sin filtro, arrastra un encabezado en el panel para reordenar esa sección en el archivo fuente.

El marcador [[toc]]

Una línea [[toc]] sola en el documento se expande a una tabla de contenidos navegable y siempre actualizada: cada vez que cambias los encabezados, la lista se regenera sola en la vista previa, sin que tengas que mantenerla a mano.

Pasa el cursor sobre [[nota]] para ver el contenido de esa nota sin salir del archivo actual.

Cursor y scroll por archivo

Al cambiar de pestaña, ComdTeX recuerda dónde estabas: cursor, posición de scroll y qué está plegado, todo junto y por archivo. Volver a un archivo tras días sin abrirlo te deja exactamente donde lo dejaste.

Vistas derivadas en vez de mantenidas a mano

Para no llevar a mano una lista de tareas o un calendario de la materia, declara un archivo generado en las reglas de la carpeta; ver Reglas de carpeta.

Continuación de listas y tablas

Al pulsar Enter se mantiene la estructura: el guion, el número (que se incrementa), la casilla - [ ], la cita > o una fila de tabla con el mismo número de columnas. Sobre un marcador vacío, Enter sale de la lista en vez de añadir otro vacío; si estaba anidado, sube un nivel. Se puede desactivar en Configuración → Editor.

Para tablas descuadradas (filas con menos columnas que la cabecera) hay un aviso en el editor y el comando Normalizar tabla, que rellena las celdas que faltan y realinea los | en un solo paso de deshacer.

Long documents

The case: you keep writing a subject class by class in the same .md, and two months in it is 3000 lines long. These are the tools that keep it manageable.

Folding headings and blocks

Every heading folds from its line up to just before the next heading of the same level or higher. Folding ## Class 3 hides that class and nothing more. Use the arrow in the left margin, or Monaco’s shortcuts:

ShortcutAction
Ctrl+Shift+[Fold the section at the cursor
Ctrl+Shift+]Unfold
Ctrl+K Ctrl+0Fold all
Ctrl+K Ctrl+JUnfold all

Headings inside code blocks are ignored: a # comment in a shell script is not a section.

Folding is remembered per file, together with the cursor and the scroll position. Switch tabs and come back, and everything is exactly as you left it.

:::excalidraw blocks fold themselves the first time you open a file, because their scene is a single base64 line that takes up half the screen. This can be turned off in Settings → Editor.

Splitting the file once it gets too heavy

Ctrl+P → "Split document into sections (##)" cuts the document at its ## headings and creates one file per section next to the original. The original keeps its preamble (frontmatter, introduction) and a list of transclusions:

---
title: Algebra II
---

![[algebra-class-1]]

![[algebra-class-2]]

![[algebra-class-3]]

The preview does not change: transclusions include the content, so the rendered document is the same as before. What you gain is that each class is an independent file, linkable with [[…]] and searchable on its own.

Safeguards:

  • Asks for confirmation before touching anything.
  • If any of the target names already exists, it splits nothing and warns you. It never overwrites.
  • Nothing is lost: the preamble plus the sections reconstruct the original.

Transclusion

Embeds content from another note without copying it, at three granularities:

SyntaxWhat it includes
![[note]]The whole note
![[note#heading]]Just that section
![[note#^id]]Just the block marked with that ^id

The content stays in sync with the original: you edit the source note and the transclusion updates itself on the next preview.

The outline as an index

The Views → Outline panel lists the headings and has a filter: type “class 7” and jump straight there. With the filter active, drag-to-reorder is disabled, since reordering a filtered list would move sections you cannot see. Without a filter, drag a heading in the panel to reorder that section in the source file.

The [[toc]] marker

A standalone [[toc]] line in the document expands into a navigable, always-current table of contents: every time you change the headings, the list regenerates itself in the preview, with nothing to maintain by hand.

Hover over [[note]] to see that note’s content without leaving the current file.

Per-file cursor and scroll

When you switch tabs, ComdTeX remembers where you were: cursor, scroll position and what is folded, all together and per file. Coming back to a file after days away leaves you exactly where you left it.

Derived views instead of hand-maintained ones

To avoid keeping a task list or a subject calendar by hand, declare a generated file in the folder rules; see Folder rules.

List and table continuation

Pressing Enter keeps the structure going: the dash, the number (which increments), the - [ ] checkbox, the > quote, or a table row with the same number of columns. On an empty marker, Enter exits the list instead of adding another empty one; if it was nested, it goes up one level. This can be turned off in Settings → Editor.

For ragged tables (rows with fewer columns than the header) there is a warning in the editor and the Normalize table command, which fills in the missing cells and realigns the | characters in a single undo step.