obsidian-vimrc-support
obsidian-vimrc-support copied to clipboard
'ciw' doesn't work properly when remaping 'i' to 'k'
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
In your case, cqw
will work instead
In your case,
cqw
will work instead Sadly this doesn't work either, it will just do the same as pressing 'w'
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 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 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 noremap
s.
@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 I'm having the same issue and it's driven me away from Obsidian for the time being. Have you found any other workarounds?
Same, no workarounds found yet I think...
@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.