When a Persian Sentence Starts with English in Obsidian

I had a small problem in Obsidian. It handles text direction automatically, but when a Persian sentence starts with an English word, the direction sometimes isn't what I want.

A sentence might start with Obsidian and continue in Persian. I still want to read that sentence from right to left.

The simplest solution for me was a snippet using the Templater plugin. It puts an invisible character called RLM at the beginning of the line's text. That character helps establish a right-to-left direction. Then I can assign a shortcut such as Ctrl+Shift+R and run it whenever I need it.

The idea is similar to using the right-hand Ctrl+Shift keys to set a paragraph's direction in Word.

Sometimes I also want an entirely English line inside a Persian note to follow that direction. So the code doesn't need to check whether the rest of the line is Persian.

I've included the code as a download in case you have the same problem.

Download the Templater template and instructions (ZIP)

Download the Markdown template directly

An example

Before running the template:

Obsidian برای یادداشت‌های فارسی من هم استفاده می‌شه.

Afterwards, its characters look like this:

[U+200F]Obsidian برای یادداشت‌های فارسی من هم استفاده می‌شه.

[U+200F] is just a visible label for the invisible character. The code inserts the RLM character itself, not those eight characters.

Setup and practical notes

Shahrzad’s note

Shahrzad:

Obsidian is a note-taking app built around Markdown files. Templater is a community plugin that can run JavaScript inside templates. The download here is a Templater template, not a separate plugin.

Install and enable Templater under Community plugins. Put obsidian-rlm-templater.md in your templates folder and select that folder under Template folder location. Bind this file to an Insert command under Template Hotkeys, rather than Create, which makes a new note. Then assign Ctrl+Shift+R to its command in Settings → Hotkeys. If that shortcut is already taken, choose an unused combination.

Select the lines you want to adjust and run the shortcut. Without a selection, it checks only the current line. The downloadable version also handles headings, lists, blockquotes and table cells. It skips frontmatter, fenced code blocks using backticks or tildes, code indented with four spaces or tabs, and $$ math blocks. Code fences inside blockquotes and lists are covered by the checks. Ambiguous cases are handled conservatively, so some lines are left unchanged, including deeply indented prose and HTML blocks.

This changes the text, not alignment settings or CSS. RLM is the invisible Unicode character U+200F. It is saved in the file and travels with copied text. Use Undo to remove an unwanted insertion, and try it on a copy of a note first.

The code deliberately does not require Persian later in a line. If you want an entirely English line inside a Persian note to follow the same direction, select it and run the template. Lines starting with Latin digits or inline code can also be changed. This is not a complete direction detector for every language or a full Markdown parser.

Obsidian also has a Right-to-left (RTL) setting under Settings → Editor → Display for the default note direction. This template is a local text adjustment. Its effect can differ between editing and Reading view because a physical Markdown line is not necessarily a separate rendered paragraph. Run it with the note open in an editor.

Updated October 19, 2026: the download now contains version 2. The earlier version did not protect some quoted or indented code blocks. That bug is fixed, along with an off-by-one selection boundary that could change the next line when the selection ended at its beginning. Accented Latin letters and Persian punctuation before English are also handled. The actual template passed 57 synthetic scenarios using an Editor API mock, not a full compatibility test across Obsidian versions and themes. With no selection it processes the current line, and with a selection it processes that range of lines. Multiple disjoint selections have not been added.

References