Skip to content

aptend/typing-transformer-obsidian

Repository files navigation

English | 中文

Typing Transformer Obsidian

Typing Transformer is a plugin packed with features that will literally transform your typing. It has clean internal rules, flexible configuration and allows users to have a customized auto-formatting experience as typing.

Typing Transformer is inspired by Easy Typing. Thanks to Easy Typing!

Note: The implementation depends on CodeMirror6 and only works in non-legacy mode in Obsidian 0.14.15 or later

Typing Transformer currently supports three types of transformation rules:

  1. Input Conversion Rules
  2. Deletion Rules
  3. Selection Rules

In addition, Typing Transformer has auto-formatting features such as inserting spaces between multiple languages and certain symbols.

What's New in 0.3.0?

  • Better README.md
  • Deletion rules
  • Selection now supports inserting multiple characters
  • Improved error messages in editor
  • Resizable rule editor
  • Fixed bugs in auto formatting (no longer adds spaces when typing URLs and time)

Special thanks to @caasion for wonderful thoughts and work in 0.3.0

Input Conversion Rules

Input conversion rules are versatile and can be used in creative ways. These include expanding abbreviated phrases, auto-pairing symbols, transofrmation of full-width characters, auto correct and more!

An input conversion rule has the following syntax:

'<trigger>' -> '<result>'

Anything in angled brackets are replaced

Example 1: Expanding Abbreviated Phrases

dpx

When dp is entered and x follows, the cursor will be after x, which triggers the conversion.

Everything will then be replaced with the result: don\'t panic|.

Note: | indicates the cursor position after the conversion. (You can place it anywhere in the text.)

Example 2: Auto-pairing of symbols

auto-pair

The trigger of the rule is and the rule auto-pairs Chinese bookmarks and places the cursor in the middle.

Example 3: Transformation of two full width characters into one half width character

auto-pair and transformation

This rule works with the one above.

  1. When a is entered, the second rule auto-pairs it.
  2. When another is entered, the first rule will take priority because it matches.
  3. The auto-pair rule won't do anything yet. This results in 《《|》.
  4. This is then converted by the first rule, by the first rule, into <.

Note: Rules that come first have higher priority, so the conversion into full width characters must come first before the auto-pairing

More examples can be found in the settings page of this plugin. Have fun converting!

Deletion Rules

Deletion rules are the reverse of input conversion rules; the deletion of a certain character acts as the trigger. These can be used with auto-pairing rules to fully power-up your typing.

A deletion rule has the following syntax:

'<deletion trigger>' -x '<result>'

Anything in angled brackets are replaced

Example 1: Deletion of a pair of brackets

pair deletion

Example 2: Quick Deletion of Asterisks

asterisks deletion

Selection Rules

Selection rules will help your insert characters on both sides of the selected text when one trigger character is entered

The syntax of a selection rule is as follows:

'<trigger>' -> '<left insert>' + '<right insert>'

Anything in angled brackets are replaced

Example 1: Selection auto-pair of

selection

The auto-pairing of angled brackets make typing HTML a lot easier!

These rules are supported by default:

'·'  -> '\`' + '\`'
''  -> '$' + '$'
''  -> '' + ''
'<'  -> '<' + '>'

Formatting Lines with Spaces

When typing in multiple languages, inserting spaces between different language blocks optimizes the reading experience. Without doubt, Typing Transformer contains functionalities that can help.

add spaces

Auto-formatting triggers by sentence fragments; the insertion of space occurs when punctuation is entered, such as commas, periods or spaces. When processing, ⭐️ (Zone Indicator) will indicate the starting point and the current cursor position will act as the end point.

Note: Auto-formatting only supports Chinese and English as of now.

To learn more about the internal workings, see How it works.md