简体   繁体   中英

How to use vim easy motion plugin movements with y/c/d commands?

I am using easymotion plugin ( https://github.com/easymotion/vim-easymotion ) with vim. If you use f/F motions in VIM (with easymotion plugin), easy motion highlights all possible positions when there are multiple matches, that way you can easily jump to the position you want.

But it doesn't work with y/c/d commands, how can I achive that ? I have provided an example below for clarification:

This is some line.

Say I am working on the above line in vim and the cursor is at the i in "This". If I do "yfs" in vim, I would like easy motion to mark the three "s"s present to the right of the cursor. That way, I can easily yank/change/delete upto the s I want.

Thanks in advance !

You can, use something like this in your .vimrc:

" Find next occurence of a char using easymotion
map  <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)

Now you can do something like y<Leader>fs and it will highlight the three s-characters. Selecting one will then yank from your cursor's position to that character.

If this does not work

This means that there are other key bindings that are using the same combination. You can check this with :map and then look for the key combination you are trying to map to the easy-motion. Removing that keybinding from your .vimrc or removing the plugin that created the binding should solve the problem.

If it's the YankRing plugin that's hijacking the y/c/d keystrokes, you can add the following to your vimrc to prevent it from doing that (Check :h yankring for more info):

let g:yankring_zap_keys = ''

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM