简体   繁体   中英

Some Surround.vim commands don't work

Just installed the surround.vim plugin and some of the commands don't work as expected. I am using this question as an example

This is a lo*ng line and I want to highlight two words

a ys2aw" should change the above to

This is a "long line" and I want to highlight two words

but for me it changes it to

This is a g and I want to highlight two words

Other times it has no affect at all! I think it has to do with what is in the yanked register.

When I am typing ys , in the bottom right I can see that it quickly changes to g@

Finally, I am pretty sure no other plugins are interfering as by issuing the verbose map yss command:

 n  yss           <Plug>Yssurround
    Last set from ~/.vim/plugin/surround.vim                                                                                                                     
 n  ys            <Plug>Ysurround
    Last set from ~/.vim/plugin/surround.vim

Does anyone know what is going wrong here?

I figured it out, to make it easier to copy/paste between vim and, well, everything else, I had the following rule in my .vimrc file:

set clipboard=unnamedplus

This makes surround.vim behave incorrectly. Instead what I did was add the following line to my .vimrc file to allow me to toggle this desired behaviour on/off

nnoremap <leader>hf :set clipboard=unnamedplus<CR>
nnoremap <leader>fh :set clipboard-=unnamedplus<CR>

and now surround.vim works as normal

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