---
title: Syntax highlighting and large file handling for nvALT
date: 2026-11-12 09:15
slug: syntax-highlighting-and-large-file-handling-for-nvalt
categories:
- Blog
- Code
tags:
- themes
- nvalt
- search
- criticmarkup
- editor
- markdown
---

[nvALT](https://brettterpstra.com/projects/nvalt) has been coloring Markdown in the editor for a while now, and the preview just learned how to color code. Both of those are nice. Neither of them was built for a note the size of a short novel, so I drew a line.

### Coloring the note you're writing

With Markdown completions on, the editor paints the syntax from your theme. Headings, emphasis, links, lists, code, `==highlight==`, and CriticMarkup all pick up the colors in the `.theme` file. If a theme never defines CriticMarkup, deletions, insertions, comments, and highlights fall back to red, green, cyan, and yellow.

That coloring is the good kind of fidgety. It makes a normal note easier to scan. It is also a scan of the note, and doing it on every keystroke is how handling a big file gets messy. Under about 300KB, an edit now recolors the lines you actually changed, plus the fenced block or critic span those lines sit in, instead of walking the whole note again.

Files over about 300KB don't get syntax highlighting anymore. [nvUltra](https://nvultra.com/ "nvUltra-Searchable, portable, MultiMarkdown notes") does a fine job of syntax highlighting on huge files, and Fletcher deserves all the credit for that, but working with the older text system on nvALT was too inefficient to handle such large texts.

### The preview got a highlighter too

Fenced code blocks in the preview run through highlight.js. A Ruby fence looks like Ruby. A bare code block, with no language on it, still gets the generic treatment. Inline `` `code` `` is left alone, and a Mermaid diagram stays a diagram.

The default colors are the GitHub light and dark token sets. Both are loaded, and both start turned off. After the page is up, the preview looks at the background behind the code. Transparent backgrounds don't count. It walks up until it finds a real color, then picks the light palette or the dark one. The cutoff is the same lightness check the rest of the app uses. The code block's own background stays whatever your preview theme already gave it.

### Put your own colors in the theme

If you want the highlighter to match a preview theme, put the classes in that theme's CSS. Those rules land after the built-in sheets, so anything you define wins.

```css
.hljs {
  color: #e5e9f0;
}
.hljs-keyword,
.hljs-type {
  color: #81a1c1;
}
.hljs-string {
  color: #a3be8c;
}
.hljs-comment {
  color: #7b88a1;
  font-style: italic;
}
```

Leave them out and you don't get a random default --- the preview still chooses the light or dark GitHub palette from the background. Specify them and it uses yours.

### Cool features, expensive notes

Syntax coloring, CriticMarkup, automatic list renumbering, closing a code fence when you hit return, the live word count. I like all of that in a note I can see on a couple of screens. On a huge note, each of them wants to read a lot more text than the character you just typed.

Past about 300KB, highlighting switches off. The theme's foreground color stays, so a dark theme like Svelte doesn't drop you into black text on a dark background, including the characters you're typing. Return inserts a return. It does not walk the file to renumber every list or to decide whether a fence is open. The word count goes blank rather than splitting a megabyte of text into words on every keystroke.

### A megabyte is fine. A novel is not.

nvALT is designed for a large pile of small notes with a fast search box in front of them. A title is an index entry. A tag is a shelf. The search field is how you find the sentence, because the sentence has its own note. That is the whole trick. A 200-page document fights it. You can't search your way to a paragraph you buried under a heading six screens down, and every edit asks the editor to understand structure that runs on for thousands of lines.

Split the long one. One note per meeting, per bug, per quote, per half-baked idea. Searching gets better, and so does editing, because the note you're in is the note you meant to open.

If you do paste in something enormous, it will no longer choke. I tried a 1MB note. You can scroll it, type in it, and press return at the end. You just don't get the fancy coloring and the automatic list fiddling while you're in there. That's the trade I wanted. Small notes stay quick and decorated. A big one stays usable.

Hopefully this improves your life in some way. Syntax highlight your code, deal with huge notes you wrote in the past. Maybe write shorter notes moving forward 😊. Oh, and scrollbars will now conistently show up for long notes as well.

**[Download nvALT v3.0.50 (179)](https://updates.designheresy.com/nvalt/nvALT3.0.50179.zip)**

A fork of Notational Velocity with Apex preview and advanced Markdown editing capabilities. Other good stuff.

[More info](https://brettterpstra.com/projects/nvalt/)

## nvALT

Project: [nvALT](https://brettterpstra.com/projects/nvalt.md)

- [New nvALT browser extensions](https://brettterpstra.com/2026/11/15/new-nvalt-browser-extensions.md): 2026-11-15
- [Syntax highlighting and large file handling for nvALT](https://brettterpstra.com/2026/11/12/syntax-highlighting-and-large-file-handling-for-nvalt.md): 2026-11-12
- [CriticMarkup, highlights, and fixes for nvALT](https://brettterpstra.com/2026/11/10/criticmarkup-highlights-and-fixes-for-nvalt.md): 2026-11-10
- [Task lists for nvALT](https://brettterpstra.com/2026/11/07/task-lists-for-nvalt.md): 2026-11-07
- [A couple of nvALT themes](https://brettterpstra.com/2026/11/06/a-couple-of-nvalt-themes.md): 2026-11-06
- [More Markdown editing features for nvALT, again](https://brettterpstra.com/2026/11/05/more-markdown-editing-features-for-nvalt-again.md): 2026-11-05
- [Mermaid and MathJax for nvALT](https://brettterpstra.com/2026/11/04/mermaid-and-mathjax-for-nvalt.md): 2026-11-04
- [Improved tagging and web clipping for nvALT](https://brettterpstra.com/2026/10/31/improved-tagging-and-web-clipping-for-nvalt.md): 2026-10-31
- [Huge improvements for Marked's Style Generator](https://brettterpstra.com/2026/10/28/huge-improvements-for-markeds-style-generator.md): 2026-10-28
- [nvALT gets themeable](https://brettterpstra.com/2026/10/27/nvalt-gets-themeable.md): 2026-10-27
- [Some new Markdown editing features for nvALT](https://brettterpstra.com/2026/10/26/some-new-markdown-editing-features-for-nvalt.md): 2026-10-26
- [OK, fine, Simplenote (and other nvALT fixes)](https://brettterpstra.com/2026/10/25/ok-fine-simplenote-and-other-nvalt-fixes.md): 2026-10-25
- [nvALT back from the dead](https://brettterpstra.com/2026/10/24/nvalt-back-from-the-dead.md): 2026-10-24
- [Rescue your nvALT Notes & Settings database](https://brettterpstra.com/2026/05/27/rescue-your-nvalt-notes-and-settings-database.md): 2026-05-27
- [A plea to nvALT users](https://brettterpstra.com/2024/04/20/a-plea-to-nvalt-users.md): 2024-04-20
- [Convert nvALT RTF files to Markdown](https://brettterpstra.com/2024/02/08/convert-nvalt-rtf-files-to-markdown.md): 2024-02-08
- [The next big thing for Marked 2](https://brettterpstra.com/2020/07/09/the-next-big-thing-for-marked-2.md): 2020-07-09
- [Markdown and code snippet management](https://brettterpstra.com/2020/04/29/markdown-and-code-snippet-management.md): 2020-04-29
- [Your August nvUltra update](https://brettterpstra.com/2019/08/07/your-august-nvultra-update.md): 2019-08-07
- [nvUltra is nvUltra](https://brettterpstra.com/2019/06/07/nvultra-is-nvultra.md): 2019-06-07
- [nvUltra update: the beta begins](https://brettterpstra.com/2019/05/29/nvultra-update-the-beta-begins.md): 2019-05-29
- [Codename: nvUltra](https://brettterpstra.com/2019/04/10/codename-nvultra.md): 2019-04-10
- [Stuff I've made (and actually use)](https://brettterpstra.com/2019/01/15/stuff-ive-made-and-actually-use.md): 2019-01-15
- [Web Excursions for April 09, 2018](https://brettterpstra.com/2018/04/09/web-excursions-for-april-09-2018.md): 2018-04-09
- [nvALT 2.2.8, because I got High (Sierra)](https://brettterpstra.com/2017/09/19/nvalt-2-dot-2-8-because-i-got-high-sierra.md): 2017-09-19
- [nvALT 2.2.7. Everything'll be fine.](https://brettterpstra.com/2016/11/14/nvalt-2-dot-2-7-everythingll-be-fine.md): 2016-11-14
- [nvALT 2.2.6 (124) because 123 is never enough](https://brettterpstra.com/2016/11/01/nvalt-2-dot-2-6-124-because-123-is-never-enough.md): 2016-11-01
- [nvALT 2.2.5 (123)](https://brettterpstra.com/2016/10/31/nvalt-2-dot-5-123.md): 2016-10-31
- [nvALT 2.2 take 2.2 (one more time, with feeling)](https://brettterpstra.com/2016/09/27/nvalt-2-dot-2-take-2-dot-2-one-more-time-with-feeling.md): 2016-09-27
- [OK, nvALT 2.2 take 2](https://brettterpstra.com/2016/09/23/ok-nvalt-2-dot-2-take-2.md): 2016-09-23
- [nvALT 2.2: bugfixes, Sierra compatibility](https://brettterpstra.com/2016/09/22/nvalt-2-dot-2-bugfixes-sierra-compatibility.md): 2016-09-22
- [An nvALT (and more) status report](https://brettterpstra.com/2015/09/14/an-nvalt-and-more-status-report.md): 2015-09-14
- [Marked 2.3 on the Mac App Store](https://brettterpstra.com/2014/07/21/marked-2-dot-3-on-the-mac-app-store.md): 2014-07-21
- [Mirror your MindMeister maps to nvALT](https://brettterpstra.com/2014/05/27/mirror-your-mindmeister-maps-to-nvalt.md): 2014-05-27
- [Folderize - Sync nvALT notes to nested folders](https://brettterpstra.com/2014/05/04/folderize-sync-nvalt-notes-to-nested-folders.md): 2014-05-04
- [2013: My year in review](https://brettterpstra.com/2014/01/01/2013-my-year-in-review.md): 2014-01-01
- [Save Pocket favorites to nvALT with IFTTT and Hazel](https://brettterpstra.com/2013/11/01/pocket-favorites-to-nvalt-with-ifttt-and-hazel.md): 2013-11-01
- [Clickable wiki links in the nvALT preview](https://brettterpstra.com/2013/08/25/clickable-wiki-links-in-the-nvalt-preview.md): 2013-08-25
- [nvALT 2.2b 106](https://brettterpstra.com/2013/06/08/nvalt2.2b106.md): 2013-06-08
- [nvremind Reminders.app bollocks](https://brettterpstra.com/2013/06/02/nvremind-reminders-dot-app-bollocks.md): 2013-06-02
- [nvremind: Automatic reminders for nvALT](https://brettterpstra.com/2013/06/01/nvremind-automatic-reminders-for-nvalt.md): 2013-06-01
- [Experiment: Send to nvALT links](https://brettterpstra.com/2013/05/10/experiment-send-to-nvalt-links.md): 2013-05-10
- [Customizing the nvALT preview](https://brettterpstra.com/2013/04/06/customizing-the-nvalt-preview.md): 2013-04-06
- [nvALT 2.2&beta; 104](https://brettterpstra.com/2013/03/24/nvalt-2-point-2-beta-104.md): 2013-03-24
- [nvALT Tag Search for Alfred 2 update](https://brettterpstra.com/2013/03/18/nvalt-tag-search-for-alfred-2-update.md): 2013-03-18
- [nvTagNavigator 1.1 with automatable tag indexing](https://brettterpstra.com/2013/02/23/nvtagnavigator-1-dot-1-with-automatable-tag-indexing.md): 2013-02-23
- [nvTagNavigator: a tag panel for nvALT](https://brettterpstra.com/2013/02/15/nvtagnavigator-a-tag-panel-for-nvalt.md): 2013-02-15
- [The next nvALT 2.2 beta is here!](https://brettterpstra.com/2013/01/14/the-next-nvalt-2-dot-2-beta-is-here.md): 2013-01-14
- [A warning: Simplenote, nvALT and deleted notes](https://brettterpstra.com/2012/11/23/a-warning-simplenote-nvalt-and-deleted-notes.md): 2012-11-23
- [Slogger tags and other developing stories](https://brettterpstra.com/2012/11/19/slogger-tags-and-other-developing-stories.md): 2012-11-19
- [External linking for nvALT notes 2: nvWikiLinker](https://brettterpstra.com/2012/09/29/external-linking-for-nvalt-notes-2-nvwikilinker.md): 2012-09-29
- [External linking for nvALT notes: Part 1](https://brettterpstra.com/2012/09/28/external-linking-for-nvalt-notes-part-1.md): 2012-09-28
- [Quick Tip: images in nvALT](https://brettterpstra.com/2012/09/27/quick-tip-images-in-nvalt.md): 2012-09-27
- [nvALT 101](https://brettterpstra.com/2012/09/07/nvalt-101.md): 2012-09-07
- [nvALT and Marked on Mountain Lion: A-OK](https://brettterpstra.com/2012/07/25/nvalt-and-marked-on-mountain-lion-a-ok.md): 2012-07-25
- [More Marky love for nvALT](https://brettterpstra.com/2012/06/28/more-marky-love-for-nvalt.md): 2012-06-28
- [nvALT 2.2 public beta](https://brettterpstra.com/2012/02/28/nvalt-2-2-public-beta.md): 2012-02-28
- [Connecting nvALT and Address Book](https://brettterpstra.com/2012/02/02/connecting-nvalt-and-address-book.md): 2012-02-02
- [A solution for scatterbrains](https://brettterpstra.com/2011/11/04/a-solution-for-scatterbrains.md): 2011-11-04
- [How to be popular at parties](https://brettterpstra.com/2011/09/02/how-to-be-popular-at-parties.md): 2011-09-02
- [Break up your text documents](https://brettterpstra.com/2011/08/29/break-up-your-text-documents.md): 2011-08-29
- [nvALT Browser Extensions](https://brettterpstra.com/2011/07/29/nvalt-browser-extensions.md): 2011-07-29
- [nvALT 2.1 in the wild](https://brettterpstra.com/2011/07/29/nvalt-2-1-in-the-wild.md): 2011-07-29
- [nvALT 2.1 progress report](https://brettterpstra.com/2011/05/20/nvalt-2-1-progress-report.md): 2011-05-20
- [nvALT 2.0: it's here](https://brettterpstra.com/2011/04/05/nvalt-2-0-its-here.md): 2011-04-05
- [Project status report, March 2011](https://brettterpstra.com/2011/03/12/project-status-report-march-2011.md): 2011-03-12
- [nvALT 1.0.8 progress and status](https://brettterpstra.com/2011/02/25/nvalt-1-0-8-progress-and-status.md): 2011-02-25
- [Quick tip: running nvALT after a Notational Velocity update](https://brettterpstra.com/2011/02/08/quick-tip-running-nvalt-after-a-notational-velocity-update.md): 2011-02-08
- [Notational Velocity update breaks nvALT](https://brettterpstra.com/2011/01/29/notational-velocity-update-breaks-nvalt.md): 2011-01-29
- [nvALT 1.0.8 progress](https://brettterpstra.com/2011/01/18/nvalt-1-0-8-progress.md): 2011-01-18
- [nvALT 1.0.7](https://brettterpstra.com/2011/01/14/nvalt-1-0-7.md): 2011-01-14
- [nvALT 1.0.5 (quick fixes)](https://brettterpstra.com/2010/12/27/nvalt-1-0-5-quick-fixes.md): 2010-12-27
- [nvALT 1.0.4: custom colors, social sharing](https://brettterpstra.com/2010/12/26/nvalt-1-0-4-custom-colors-social-sharing.md): 2010-12-26
- [Speaking of Notational Velocity, did you know...](https://brettterpstra.com/2010/12/11/speaking-of-notational-velocity-did-you-know.md): 2010-12-11

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
