esm7 / obsidian-vimrc-support

A plugin for the Obsidian.md note-taking software
MIT License
1.05k stars 46 forks source link

Need help with simple remap #166

Open EricEWeir opened 1 year ago

EricEWeir commented 1 year ago

I'm a noncoder trying to implement simple vim-mode mappings. They are:

set clipboard=unnamed
map k gk
map j gj
map H ^
map L $
map jj <ESC>

The H and L remaps don't work. Neither does the <ESC>. remap.

I started with noremap mappings. On suggestions encountered here I also tried imap and map. With I also tried inoremap I'm guessing none of the is right for <ESC>.

Help appreciated.

jiyee commented 1 year ago

Have a try as below:

nmap H ^
nmap L $
imap jj <Esc>
karpovichpv commented 1 year ago

for this mapping:

map jj <ESC>

perfectly work this one

imap jj <Esc>
EricEWeir commented 1 year ago

I have these:

nmap H ^
nmap L $
imap jj <ESC>

nmap H ^ Takes cursor to top of file. nmap L $ Takes cursor to bottom of file. imap jj <ESC> Enters jj

I have vimrc-support plugin enabled. Also Obsidian vim key bindings.

EricEWeir commented 1 year ago

If anybody has a clue about why these key bindings aren't working for me I'd greatly appreciate help. I gather they work for others.Especially miss the binding on my mobile devices.

Again, Obsidian's vim key bindings and the vimrc-support plugin are enabled on all devices.

karpovichpv commented 1 year ago

If anybody has a clue about why these key bindings aren't working for me I'd greatly appreciate help. I gather they work for others.Especially miss the binding on my mobile devices.

Again, Obsidian's vim key bindings and the vimrc-support plugin are enabled on all devices.

Hello, try this:

  1. Create file .obsidian.vimrc
  2. Write in this file next lines:
imap jj <Esc>
nmap H gg
nmap L G
  1. copy this file to your current obsidian vault-folder
  2. switch on vim mode
  3. reload the program
EricEWeir commented 1 year ago

Thanks. I tried it. Same results.

gg and G don't need to be mapped. It seems they're already provided for in Obsidians native vim mode

fmontagut commented 1 year ago

Hi @EricEWeir, I had a similar issue, and I cannot reproduce how I fixed it, but I will share my experience. I had a .obsidian.vimrc with:

nmap j gj
nmap k gk, both worked
a few lines below, I had
imap  jk <Esc>, and jk in insert mode didn't work.

I had a combination of issues: I wrote originally "ESC" instead of "Esc", corrected and no changes. My configuration started to work once I moved the imap jk line at the beginning of my .obsidian.vimrc, and I commented the nmap lines. What is interesting is that I moved back to where it was originally, and I uncommented the nmap lines, and all mappings works without issues.

I have Obsidian v1.1.15 installed with Vimrc support plugin 0.9.0