MH Default Note Width & View

unlisted

by MH - Matheus Heidemann

Set default note width, view mode, and scroll position from templates, rules, or frontmatter.

Updated 2mo ago
View on GitHub

MH Default Note Width & View

Summary

MH Default Note Width & View is an Obsidian plugin that applies a default note width, view mode, and optional scroll position to matching Markdown notes.

The plugin is now maintained as TypeScript source under src/. The root main.js file is a generated esbuild bundle and should not be edited manually.

Purpose And Features

  • Create reusable templates for note width, view mode, and scroll behavior.
  • Apply templates directly from frontmatter with a configurable property.
  • Apply templates automatically with ordered rules.
  • Match rules by folder, path, note name, tags, or frontmatter property.
  • Combine rule conditions with all, any, or none.
  • Choose one of three width modes: readable line length, percentage width, or fixed pixel width.
  • Choose one of three view modes: reading view, live preview editing, or source editing.
  • Optionally scroll matching notes to the top or bottom after opening.
  • Use English or Brazilian Portuguese locale files from locales/.
  • Use MH-API-TEMPORARY when available for richer rule evaluation and settings UI components, with local fallbacks when it is unavailable.

How It Works / How To Use

Create one or more templates in the plugin settings. A template defines width, view mode, and scroll position.

Available width modes:

  • Readable line length: toggles Obsidian's native readable line length class for the managed note.
  • Percentage: centers the note content and limits it to a percentage of the available pane width.
  • Pixels: centers the note content and limits it to a fixed pixel width.

Available view modes:

  • Reading view
  • Editing view (Live Preview)
  • Source editing view

Available scroll positions:

  • Disabled
  • Top of note
  • Bottom of note

To apply a template directly from frontmatter, use the configured template property. The default property is mh-default-note-width-and-view-template, and its value must match the template name.

---
mh-default-note-width-and-view-template: Wide Reading
---

Rules are evaluated after the frontmatter override. The first enabled matching rule wins. Rules can match by folder, path, note name, tags, or a frontmatter property.

Example rule setup:

  • Template: Wide Reading
  • Match mode: all
  • Condition 1: folder contains Daily
  • Condition 2: tags includes #journal

Example property-based rule:

---
layout: dashboard
---

Use a rule condition with source property, property name layout, operator is, and value dashboard.

Settings available:

  • Language
  • Frontmatter template property name
  • Templates
  • Ordered rules

Template priority:

  1. Frontmatter template property.
  2. First enabled matching rule.
  3. No template is applied.

Installation

For a manual Obsidian installation, place these files in .obsidian/plugins/mh-default-note-width-and-view/:

  • main.js
  • manifest.json
  • versions.json
  • locales/en-us.json
  • locales/pt-br.json

No styles.css file is required. Width styles are injected by the plugin at runtime.

After copying the files, reload Obsidian and enable MH Default Note Width & View in Community Plugins.

Development

Install dependencies:

npm install

Run a development build with watch mode:

npm run dev

Run TypeScript validation:

npm run typecheck

Build the production bundle:

npm run build

Check the generated bundle syntax:

node --check main.js

Development entrypoint:

src/main.ts

Production output:

main.js

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.