0

I am learning vim and slowly but surely adapting my vimrc.

I am moving around with "jlim" and entering insert mode with k. All I want to do is combine actions with text-objects.

But when I want to change inner word (should be c k w) for me I go one line up instead of change the inner word. I have checked :index and :c and :iw but I dont understand how to map my actions to inner word??

vimrc:

`" set move keys in vim
   map m <down>
   map i <up>
   map j <left>
   map l <right>
`

greetings

SOLUTION to "{action} {text object}" while k is insert:

" set move keys in vim
nnoremap m <down>
nnoremap i <up>
nnoremap j <left>
nnoremap l <right>

" n for normal mode and noremap to not make k map to up
nnoremap k i

2 Answers2

1

If you just want to change all the things that i does to k (which I'd advise against, they are mnemonics for a reason), you can just map it.

That being said, bare map is overkill. You'll be better off with noremap which won't recursively change your mappings. You'd also be better off specifying the mode you want these mappings to use. If you have to change the movement keys (which I also wouldn't recommend), I'd suggest

nnoremap m <down>
nnoremap j <left>
nnoremap l <right>
nnoremap i <up>

Then you can change what you want k to do with just another nnoremap:

"n for normal mode, noremap for not making your k map to <up>
nnoremap k i
jeremysprofile
  • 10,028
  • 4
  • 33
  • 53
  • Sadly I can't give upvotes yet but thank you for the explanation of map and noremap! – sendHelpImAskingqq Apr 30 '20 at 15:04
  • FWIW, I don't think the person whose answer you accepted is correct. I tested doing `nnoremap k i` and it appears to do all the `i`nner changes correctly. `ckw`, `ck(`, etc, "just work" with the one remap. – jeremysprofile Apr 30 '20 at 15:09
1

If I understand correctly you are looking for :h onoremap if you want ckw to do ciw you need

:onoremap kw viw

This would be necessary for all types of bracket (for i inner and a around movement (ciw and caw)). I would not recommend that. Just stick with the default.

Chelz
  • 437
  • 1
  • 4
  • 9