Using VIM to render visual documents

2021-09-10 @Technology

A couple of persons very recently questioned me on VIM’s capacity to render visuals. The notion of VIM as a plain-text editor often produces some confusion to this regard. I’ll thus take the opportunity to dispel a common misconception concerning this powerful text editor.

VIM - the open-source text editor, as the description suggests, fundamentally edits plain text. Though efficient, fast, and light per the default setup, its power comes especially from the cohort of meta features: macros, aliases, abbreviations, automations and the means to optimize or entirely redefine any and all operations common or important to your style and workflow.

It’s sometimes referred to as a ‘programmers text editor’ since it functions entirely based on keyboard input: no visual distractions, menus, toolbars, or noise of the sort.

(Case point, the GVIM variant, still almost as light, does feature a mouse-operable menu of common functionality, but any beyond a novice user wouldn’t find any benefit to this, since the pseudo-interface hampers much efficiency ultimately attainable through effective usage.)

The power comes from the keyboard means of operation: which can bear semblance to an interface for hackers, from which the notion of an ‘editor for programmers’ likely originates. However, anyone can adapt to it, and the use cases, as I will shortly demonstrate, far expand beyond ‘programming’, and could address the needs of even a bakery clerk.

VIM to render any visuals

With VIM you edit plain text, yes. However, that text can be a particular source/schema/script which, through an intermediary, renders a PDF, an image, or even an executable.

Similarly with HTML: though effectively plain text (a particularly formatted schema), it instructs the web browser to render any combination of formatted and styled text, visuals or multimedia. Naturally, you can (and should) also edit HTML with VIM. :)

Something like a word processor, on the other hand, combines both text editing and the stylistic/visual rendering in one monolithic package: also packing a lot of visual and performance bulk. MS Word (or the open-source variant Libre Office) directly interface with binary formats, not plain text: and being binary, they can include text and graphical elements.

But you need not yield to the cumbersome and point-click shackles of a word processor. VIM can render anything a Word Processor can, but it operates via an abstraction paradigm: the editing part is made optimal, efficient and non-invasive - leveraging text or respective schemas. The specific post-processor then renders the resulting binary document: PDF, JPG, a Unix man page, an EPUB, etc.

Different source formats for ranging visual outputs

Learn and use the Latex schema to produce styled or scientific documents, books, presentation slides, diagrams, ebooks. Most of the time, you’ll generate a PDF, which can display virtually anything you might conceive of. Though steep the learning curve, the investment is powerful if you often produce styled documents of any kind and wish to transition away from a life of heavy word processors or proprietary presentation formats.

Use the simpler formatted Markdown schema to also render styled documents and slide presentations, though of lesser complexity than Latex enables. Depending on the chosen output, the Markdown renderer (ie Pandoc) might leverage the Latex engine as an intermediary. Most conveniently, the Markdown syntax requires hardly any time to grasp.

See my example on generating quick presentation slides in Markdown via Pandoc.

Types of rendered documents for a sample of plain-text schemas

Source input Commonly rendered documents Rendering engine
Latex PDF: styled, scientific, book, slides, diagrams, etc), EPUB pdftotex (and others)
Markdown PDF, HTML, slides pandoc (sometimes via Latex), and others
groff PDF, HTML, man pages, … nroff (and more)
gnuplot, asymptote (diagrams, plots) PDF, JPG, PNG, … same
source code interpreted or binary executable varies

Latex and Pandoc related links

Questions, comments? Connect.