How to set leader key for vim mode and some keybindings using it?

Things I have tried

  • Putting let mapleader = " " in my .obsidian.vimrc file but it doesn’t work
  • setting keybinding (in .obsidian.vimrc) like this:
exmap openGraph obcommand graph:open
nmap <leader>og openGraph

but it won’t work without setting the leader key first.

What I’m trying to do

I’m trying to set leader key to space and set some keybindings with it.
I googled and searched this forum a lot today and I can’t find a single example of setting the leader key. Can anybody help me with it? Thank you.

You need to unmap <Space> first.

See GitHub - esm7/obsidian-vimrc-support: A plugin for the Obsidian.md note-taking software

I unmapped space in my .obsidian.vimrc with unmap <Space>. Now what? How to map space as leader or create key chord with it? I tried adding this to my .obsidian.vimrc:

exmap openGraph obcommand graph:open
nmap <leader>og openGraph
nmap <Space>og openGraph

But pressing <Space> o g in normal mode doesn’t display graph (it only creates new line as if I pressed only o). What am I missing? When I run manually :openGraph it works as it should.

You’re missing colons

Thank you very much, it works now!

It works when I use Space directly like this:
nmap <Space>og :openGraph

Do you know if it is actually possible to set space as leader key and use <leader> notation in my .obsidian.vimrc? Like this:
nmap <leader>og :openGraph

2 Likes

Sorry I haven’t tried it.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.