• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A plugin for Obsidian providing hotkeys that select words and lines in a smart way before applying markup. Multiple cursors are supported as well.

🧠 Smarter Markdown Hotkeys

Obsidian Downloads

A plugin for Obsidian providing hotkeys that select words and lines in a smart way1 before applying markup. Multiple cursors are supported as well.


Note
Looking for Co-maintainer: I simply have too many open source projects and therefore do not have the time to maintain this plugin regularly. So if you are interested in co-maintaining the plugin, feel free to contact me.


Demo Video

Table of Contents

Markup Commands with Smart Expansion

  • Smarter Bold
  • Smarter Italics
  • Smarter Underscore Bold (__foobar__)
  • Smarter Underscore Italics (_foobar_)
  • Smarter Comment*
  • Smarter HTML Comment*
  • Smarter Inline/Fenced Code*
  • Smarter Highlight
  • Smarter Bold & Highlight2
  • Smarter Italics & Highlight2
  • Smarter Strikethrough
  • Smarter Markdown/Image Link
  • Smarter Wikilink (Internal Link)
  • Smarter Wikilink with Heading
  • Smarter Mathjax*
  • Smarter Callout Label

All commands also support multiple cursors, smart inclusion/exclusion of special characters, and undoing markup by triggering the same hotkey.

* These commands wrap whole blocks instead of wrapping each line when the hotkey is triggered on a multi-line selection. They also switch to the appropriate syntax, for example from inline code syntax to fenced code syntax. (See below for details.)

Command-Specific Details

The following commands have some special features:

Smarter Markdown/Image Link

  • Auto-Insert URLs: When you use Smarter Markdown Link and have an URL in your clipboard, the URL will automatically get inserted as well.
  • Automatic Switch to Image Syntax When the URL in the clipboard ends with an image extension like .png,3 the command will also prepend the ! for image links.

Smarter Inline/Fenced Code

  • Terms instead of Words: Smarter Code will not consider punctuation or brackets as delimiters. This means that a cursor anywhere in "object.method" will select the whole term and result correctly in "object.method" instead of "object.method". (Similar to WORD in Vim.)
  • Automatic Switch to Fenced Code Syntax: When more than one line is selected, Smarter Code will wrap the selected lines in fenced code syntax instead. Furthermore, the cursor is moved to the beginning of the fenced code block so you can conveniently enter the code language.
  • 💡 Smarter Fenced Code synergizes well with the Codeblock Completer Plugin.

Smarter Comment

  • Automatic Switch to Block Comments: When more than one line is selected, the Smarter Comment commands will expand the selection to whole blocks and then wrap all of them together into the comment syntax.

Smarter Wikilink

  • Auto-Suggest: When turning text into a wikilink, Smarter Wikilinks will trigger the suggester afterwards.
  • Wikilink a Heading: Alternative command that inserts the syntax for a markdown link to a heading, and also triggers the Suggester after doing so. (i.e., instead of [[ ]], it uses [[## ]]).

Smarter Mathjax

  • Automatic Switch to Blocks: When more than one line is selected, the Smarter MathJax command will also expand the selection to whole blocks and switch from $ to $$. (I do not use Mathjax myself, so feel free to open an issue when the Mathjax command can be improved somehow.)

Smarter Callout Label

Turns the text under the cursor into a callout label.

Demo Demo Smarter Callout Label Command

Non-Markup Commands with Smart Expansion Logic

Smarter Punctuation Commands

While strictly speaking quotation marks and brackets are not a form of markup, I found it quite useful to be able to set them in the same way. Therefore, the following commands have been added as well.

  • Smarter Quotation Marks
  • Smarter Round Brackets
  • Smarter Square Brackets
  • Smarter Curly Brackets

When there is no selection, the the Smarter Punctuation Commands essentially emulate ysiw", ysiw), ysiw], and ysiw} from vim-surround.

Smarter Case Switching

The same logic can also be applied to case switching commands. First, the selection is expanded to whole words. Then, the casing of the whole selection is changed. Instead of having multiple hotkeys for each type of casing, this command smartly switches the case depending on the current state.

  • lower caseSentence case*
  • Sentence case* → UPPER CASE
  • UPPER CASElower case
  • OTheRSentence case

This allows you to repeatedly press the hotkey to achieve a certain result, e.g. two times on a lowercase word to make it UPPERCASE.

* Sentence case means that the first letter of the string will be capitalized, like in an English sentence. If the string only contains one word, Sentence case produces the same result as Capital Case.

Smarter Delete Text

Deletes text with the same text-expanding logic from the smarter markdown commands. (This command is similar to daw in Vim.)

Commands without Smart Expansion

These commands have simply been added for convenience. They do not use any kind of selection expansion, but are still attempts to improve the normal commands they correspond to.

Smarter Toggle Heading

Increases the Heading Level of the line under the cursor by 1. If already at 6, removes the heading instead. Intended for pressing it quickly multiple times, e.g. pressing the hotkey 3 times to turn a normal line into a h3.

Demo Smarter Toggle Heading Command

Smarter Insert New Line

Inserts line break, even when the cursor is in a nested list. Pressing return in a nested list normally inserts a line break followed by a indented list marker. (This command is essentially the same as o in Vim.)

Smarter Delete Current Note (deprecated)

Deletes the current note, but also goes back to the last file instead of leaving an empty pane. (This requires Confirm File Deletion in the Obsidian settings to be disabled.)

Deprecated. With recent versions of Obsidian, deleting a file does not result in empty panes, so this command is now basically obsolete. The command is only left in the plugin to ensure people's hotkeys do not break.

Smarter Copy Path

Press once to copy the vault-relative path of the current file, press a second time to copy the absolute path. Press a third time to copy the (vault-relative) path to the parent folder.

Smarter Copy File Name

Press once to copy the name of the current file without extension, press a second time to copy it with extension.

Toggle Readable Line Length & Toggle Line Numbers

These do pretty much what the name says.

How the Smart Expansion works in detail

Inline code signifies the part of the text being selected. | is a cursor without selection. This table serves as a reference for the precise mechanics of this plugin.

Normal Hotkeys Smarter Hotkeys
foo|bar foo****bar **foobar**
foobar f**oo**bar **foobar**
Lorem Ipsum Lor**em Ips**um **Lorem Ipsum**
- [ ] foobar ^123 **- [ ] foobar ^123** - [ ] **foobar** ^123
## Lorem Ipsum ==## Lorem Ipsum== ## ==Lorem Ipsum==
- Lorem
- Ipsum
- Lor**em
    - Ips
**um
- **Lorem**
    - **Ipsum**
**foo|bar** (Undo) **foo****bar** foobar
**Lorem Ipsum** (Undo) **Lor**em Ips**um** Lorem Ipsum

You can take a look which characters exactly are included or excluded by taking a look at the const.ts.

Setting the Hotkeys

If you want to replace the default commands from Obsidian, remember to remove their hotkey binding before changing the hotkeys from this plugin. Example for Smarter Bold:

  1. Remove the hotkey cmd/ctrl + B4 for the default command Toggle Bold.
  2. Assign cmd/ctrl + B as the hotkey for the command Smarter Bold.

💡 For the Smarter Punctuation Commands, you can also use a hotkey with shift, e.g. shift + 2 for Smarter Quotation Marks. Curiously, Obsidian accepts such hotkeys, so you can basically "overwrite" normal punctuation typing if you want to.

However, note that this comes at the cost of losing the ability to type punctuation normally. Also, this does seem to result in minor bugs, e.g. interference with Obsidian's in-document search.

Installation

The plugin is available in Obsidian's Community Plugin Browser via: SettingsCommunity PluginsBrowse → Search for "Smarter Markdown Hotkeys"

Contribute

The easiest way to make contributions is to make changes to const.st, since the constants there determine commands and what to include/exclude.

Please use the .eslintrc configuration located in the repository and run eslint before doing a pull request, and do not use prettier. 🙂

# Run eslint fixing most common mistakes
eslint --fix *.ts

About the Developer

In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch!

Profiles

Donate

Buy Me a Coffee at ko-fi.com

If you feel very generous, you may also buy me something from my Amazon wish list. But please donate something to developers who still go to college, before you consider buying me an item from my wish list! 😊

Amazon wish list

Credits

Thanks to @SkepticMystic for his support during development.

⬆️ Go Back to Top

Footnotes

  1. When there is no selection, the smart expansion is essentially equivalent to ysiw{markup} from vim-surround, but with less keystrokes.

  2. These commands are mostly used for Multi-Color Highlights that some Obsidian themes like Sanctum or Shimmering Focus offer. 2

  3. The supported image extensions are listed here.

  4. macOS uses cmd, Windows and Linux use ctrl.

More Repositories

1

shimmering-obsidian

Alfred Workflow with dozens of features for controlling your Obsidian vault.
JavaScript
811
star
2

nvim-spider

Use the w, e, b motions like a spider. Move by subwords and skip insignificant punctuation.
Lua
580
star
3

nvim-various-textobjs

Bundle of more than 30 new text objects for Neovim.
Lua
510
star
4

shimmering-focus

Minimalistic Obsidian Theme for keyboard-centric users.
CSS
469
star
5

nvim-scissors

Automagical editing and creation of snippets.
Lua
327
star
6

nvim-recorder

Enhance the usage of macros in Neovim.
Lua
202
star
7

nvim-genghis

Lightweight and quick file operations without being a full-blown file manager.
Lua
195
star
8

nvim-early-retirement

Send buffers into early retirement by automatically closing them after x minutes of inactivity.
Lua
170
star
9

nvim-origami

Fold with relentless elegance.
Lua
160
star
10

nvim-tinygit

A lightweight bundle of commands focussed on swift and streamlined git operations.
Lua
143
star
11

alfred-bibtex-citation-picker

Citation picker & lightweight reference manager for BibTeX files, via Alfred.
JavaScript
138
star
12

nvim-rip-substitute

Perform search and replace operations in the current buffer using a modern user interface and contemporary regex syntax.
Lua
133
star
13

nvim-kickstart-python

A launch point for your nvim configuration for Python
Lua
113
star
14

pandoc_alfred

Pandoc-Suite for Academic Writing in Markdown
JavaScript
98
star
15

obsidian-theme-design-utilities

Some Utilities and Quality-of-Life Features for Designers of Obsidian Themes
TypeScript
95
star
16

nvim-chainsaw

Speed up log creation. Create various kinds of language-specific log statements, such as logs of variables, assertions, or time-measuring.
Lua
92
star
17

finder-vim-mode

Feature-rich mouseless control of macOS Finder, inspired by vim/ranger.
Shell
81
star
18

.config

My personal dotfiles
Python
74
star
19

pdf-annotation-extractor-alfred

Alfred Workflow to extract annotations from PDF files.
JavaScript
72
star
20

nvim-rulebook

Add inline-comments to ignore rules, or lookup rule documentation online.
Lua
69
star
21

nvim-lsp-endhints

Display LSP inlay hints at the end of the line, rather than within the line.
Lua
66
star
22

nvim-puppeteer

Automatically convert strings to f-strings or template strings and back.
Lua
56
star
23

obsidian-divide-and-conquer

An Obsidian plugin that provides commands for bulk enabling/disabling of plugins. Useful for debugging when you have many plugins.
TypeScript
55
star
24

obsidian-quadro

Obsidian Plugin for social-scientific Qualitative Data Analysis (QDA). An open alternative to MAXQDA and atlas.ti, using Markdown to store data and research codes.
TypeScript
49
star
25

zsh-magic-dashboard

Pressing "enter" on an empty buffer displays an information-rich and pretty dashboard.
Shell
48
star
26

grappling-hook

Obsidian Plugin for blazingly fast file switching. For those who find the Quick Switcher still too slow.
TypeScript
44
star
27

nvim-alt-substitute

A substitute of vim's :substitute that uses lua patterns instead of vim regex. Supports incremental preview.
Lua
43
star
28

new-tab-default-page

Obsidian plugin to open a note of your choice when creating a new tab, like in the browser.
TypeScript
42
star
29

cmp-nerdfont

nvim-cmp source for nerdfont icons
Lua
40
star
30

alfred-neovim-utilities

Search neovim plugins and online :help via Alfred
JavaScript
34
star
31

cmp_yanky

cmp-source for clipboard history from yanky.nvim
Lua
34
star
32

nvim-dr-lsp

Status line component showing the number of LSP definition and reference of the token under the cursor.
Lua
27
star
33

alfred-docs-searches

Search more than two dozen official documentation sites via Alfred
JavaScript
25
star
34

twitter-workspace-for-drafts

Various capabilities for composing tweets in the Drafts app.
22
star
35

obsidian-sembr

Obsidian Plugin for Semantic Line Breaks
TypeScript
22
star
36

nvim-pseudometa-plugin-template

A template for new nvim plugins
Shell
22
star
37

alfred-reddit-browser

Browse your favorite subreddits (and hackernews) via Alfred.
JavaScript
20
star
38

obsidian-footnote-indicator

Indicates the presence of footnotes in the gutter and the Status bar
Shell
20
star
39

alfred-atop

System Monitoring and Process Management via Alfred
JavaScript
19
star
40

gitfred

Helpful GitHub Assistant for Alfred.
JavaScript
17
star
41

alfred-homebrew

Search, install, or uninstall homebrew packages conveniently via Alfred.
JavaScript
16
star
42

pdf-summarizer-alfred

Get summaries of your PDFs via ChatPDF.
Shell
14
star
43

hyper-seek

Alfred workflow that shows inline search results, without a keyword.
JavaScript
13
star
44

obsidian-extra-md-commands

Obsidian plugin that adds various commands, e.g. for __bold__ or <cite>.
TypeScript
12
star
45

alfred-writing-assistant

Autocorrection, synonym suggestions for the word under the cursor, and rephrasing of the selected text. All with one key press.
JavaScript
12
star
46

obsidian-sidebar-toggler

Finer control of the Obsidian sidebars. To be used with an external window manager.
TypeScript
11
star
47

wrench-knife

Collection of useful snippets for Hammerspoon
Lua
11
star
48

obsidian-nothing

An Obsidian plugin that adds a no-op command.
Shell
11
star
49

alfred-workflow-template

Shell
10
star
50

pseudometa-obsidian-plugin-template

A description for the plugin
JavaScript
9
star
51

pdf-annotation-extractor

Extracts Annotations from PDFs as well-formatted markdown
JavaScript
9
star
52

alfred-themes

A small collection of Alfred Themes I designed
8
star
53

alfred-pass

Alfred Client for the pass-cli
Shell
8
star
54

dotfiles-old

pseudometa's dotfiles
TeX
7
star
55

obsidian-smarter-paste

Improvements for when you paste things into Obsidian
TypeScript
7
star
56

alfred-wikipedia-suggest

Get in-line Wikipedia search suggestions
JavaScript
7
star
57

alfred-read-later

Simple standalone read-later-app for Alfred. Saves the items in plaintext on your device.
JavaScript
7
star
58

alfred-steam-companion

Alfred Workflow that interacts with Steam. Launches games directly, creates aliases, uninstalls games, and searches the Steam Store
6
star
59

drafts-snooze

Combination of settings, draft actions and shortcuts to enable the snoozing of drafts.
5
star
60

obsidian-task-statusbar

Obsidian plugin that displays the number of completed and total tasks in the status bar.
Shell
4
star
61

portfolio-performance-alfred

Searches your watchlists in the Portfolio Performance App for securities. Select one to copy its Name, Symbol, ISIN, or WKN to the clipboard.
JavaScript
4
star
62

alfred-anime-search

Search animes listed in the myanimelist database. Open entries at myanimelist or AniList.
JavaScript
3
star
63

tot-alfred

Tot.app Integration for Alfred.
JavaScript
3
star
64

chrisgrieser

2
star
65

axelrod-prisoner-dilemma

Recreation of the prisoner's dilemma model from Axelrod's "Evolution of Cooperation" in Python
Python
2
star
66

obsidian-personal-plugin

Personal Obsidian plugin, containing features customized to my workflow.
TypeScript
2
star
67

apuz-gender-analyzer

Analysis of the genders of the authors at the German journal "Aus Politik und Zeitgeschichte" (APuZ)
Python
2
star
68

quadro-example-vault

Example vault for Quadro, the QDA Plugin for Obsidian.
Makefile
2
star
69

alfred-reminders-companion

Display and edit reminders due today.
JavaScript
2
star
70

name-gender-analyzer

Makefile
1
star
71

test-repo

This repo is currently only used for testing GitHub Release Actions
Shell
1
star
72

nanotipsforvim-blog

source for the blog
Just
1
star
73

alfred-japanese-dictionary

Japanese-English Dictionary using jisho.org with audio, csv export of words, and preview of dictionary sites.
JavaScript
1
star
74

alfred-workflow-devtools

Various utilities and quality-of-life-features for Alfred workflow developers
Shell
1
star
75

alfred-dock-switcher

Switch between dock layouts.
Shell
1
star
76

alfred-quick-file-access

Quickly access recent files, files with a specific tag, files in the current window, files in the downloads folder, or trashed files.
JavaScript
1
star