Vim Commands

by Mateusz Kowalczyk
5
4
3
2
1
Score: 50/100

Description

Map any Obsidian command to Vim-style multi-key sequences that work everywhere, not only in the editor.

Reviews

No reviews yet.

Stats

0
stars
370
downloads
0
forks
87
days
86
days
87
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
56
commits

Latest Version

3 months ago

Changelog

Changes

  • Fix broken link to example config in README

README file from

Github

Vim Commands

Bring Vim-style command mappings to all of Obsidian:

  • Map multi-key sequences, leaders, and modified keys to any Obsidian command.
  • Use mappings across tabs, sidebars, and other app views, not only the editor.
  • Keep mappings in a vault-local, vimrc-style config file.

Vim Commands works with core commands and commands added by community plugins (everything you can find in command palette).

It stays out of text fields and Vim insert mode.

This plugin extends Obsidian's built-in Vim mode; it does not replace it. Enable Obsidian's Vim key bindings to get standard Vim editing and use these command mappings inside the Markdown editor.

Usage

  1. Enable Settings → Editor → Vim key bindings.
  2. Install and enable Vim Commands.
  3. Create .vimrc in the root of your vault. You can start from the LazyVim-inspired config.
  4. Add mappings using this form (examples below):
nmap <keys> :obcommand <command-id><CR>
  1. Reload the plugin after editing the file.

Change the file path under Settings → Vim Commands → Config file path if you keep these mappings elsewhere. The path must be inside the vault.

Only nmap ... :obcommand ...<CR> and let mapleader = "..." are handled; unrelated vimrc lines are ignored. The default <Leader> key is <Space>.

If a key combination conflicts with an Obsidian hotkey, unassign that hotkey under Settings → Hotkeys first.

To inspect available command IDs, open the developer console (View → Toggle developer tools or Ctrl+Shift+I / Cmd+Option+I) and run:

Object.entries(app.commands.commands).map(([id, command]) => [id, command.name]);

Mini Vimrc

Mini Vimrc complements this plugin well: Mini Vimrc configures editor behavior such as inoremap jk <Esc> and motion remaps, while Vim Commands invokes Obsidian commands throughout the app.

Mapping examples

let mapleader = ","

" Open the command palette and search
nmap <Leader>: :obcommand command-palette:open<CR>
nmap <Leader>/ :obcommand global-search:open<CR>

" Open the quick switcher
nmap <Leader><Space> :obcommand switcher:open<CR>

" Move between tabs
nmap H :obcommand workspace:previous-tab<CR>
nmap L :obcommand workspace:next-tab<CR>

" Commands from community plugins work too
nmap <Leader>gg :obcommand obsidian-git:open-git-view<CR>

LazyVim-inspired config

The examples/lazy.vimrc file is a ready-to-adapt, LazyVim-inspired starter based on LazyVim key mappings. Copy it to <vault>/.vimrc, trim what you don't need, and reload the plugin. Obsidian-specific commands are grouped under <Leader>o*.