obsidian-vimrc-support icon indicating copy to clipboard operation
obsidian-vimrc-support copied to clipboard

'ciw' doesn't work properly when remaping 'i' to 'k'

Open simonsanchezart opened this issue 2 years ago • 9 comments

Hi, I'm trying to configure my .vimrc for Obsidian, this is what it looks like:

set clipboard=unnamed
nmap <F9> :nohl
 
noremap i k 
noremap k j
noremap j h

noremap q i

noremap <C-i> { 
noremap <C-k> }
noremap <C-j> b
noremap <C-l> w
noremap <C-c> y

I'm remapping I to K, so I moves a line up in Normal Mode. However, if I attempt to to ciw, it will interpret it as 'change the line above' instead of 'change inside word'.

Any work around this? Thanks

simonsanchezart avatar Mar 15 '22 21:03 simonsanchezart

In your case, cqw will work instead

twio142 avatar Apr 07 '22 08:04 twio142

In your case, cqw will work instead Sadly this doesn't work either, it will just do the same as pressing 'w'

simonsanchezart avatar Apr 07 '22 23:04 simonsanchezart

The problem is, that noremap isn't supported, only map. (If you type :nnoremap i k interactively in Obsidian, it will say that it's not supported)

being able to only use nmap, these three lines will essentially map i to h... 🙈

nmap i k 
nmap k j
nmap j h

However, you can work around those restrictions by using synonyms you are not using. Since hjkl uses the arrow keys as synonyms, this would work:

noremap i <Up>
noremap k <Down>
noremap j <Left>

chrisgrieser avatar May 17 '22 11:05 chrisgrieser

@chrisgrieser I'm trying to move hjkl to jkl' since those are my home keys, and am trying exactly what you're describing, but it's not having any effect at all. This is my .obsidian.vimrc:

noremap j <Left>
noremap k <Up>
noremap l <Down>
noremap ' <Right>

I previously tried this as the solution, which works in vim, but in obsidian it works for the jkl' keys, but causes my arrow keys to be messed up in turn.

noremap j h
noremap k j
noremap l k
noremap ' l

Signynt avatar May 28 '22 12:05 Signynt

@Signynt oh sorry, I said the right thing, but posted the wrong thing in the code block.

You need nmap, not nnoremap, since Obsidian does not support noremaps.

chrisgrieser avatar May 28 '22 12:05 chrisgrieser

@chrisgrieser Unfortunately doing that makes all the keys (both jkl' and arrow keys) do the same thing, namely the last definition.

nmap j <Left>
nmap k <Up>
nmap l <Down>
nmap ' <Right>

This for example makes everthing go right one letter.

One thing I definetly don't get is why the arrow keys are being remapped, despite them not being defined anywhere. noremap does seem to work, as per my second example above, just that it also remaps the arrow keys, which I don't want.

Signynt avatar May 28 '22 14:05 Signynt

@Signynt I'm having the same issue and it's driven me away from Obsidian for the time being. Have you found any other workarounds?

Acumane avatar Jan 01 '23 00:01 Acumane

Same, no workarounds found yet I think...

fithurriague avatar Aug 18 '23 20:08 fithurriague

@Signynt I'm having the same issue and it's driven me away from Obsidian for the time being. Have you found any other workarounds?

What are you using instead? I might end up moving to vscode, the main issue for me is that the most popular latex (math code) snippet extension seems to use telemetry and I am not convinced by the others I saw.

My main difficulty with vim on obsidian is mapping d to "_d . Perhaps i can use one of the keyboard shortcut plugins and map the commands i usually use with d to one of those using obcommand or something.

userrand avatar Sep 03 '23 04:09 userrand