emacs-evil / evil-surround

you will be surrounded (surround.vim for evil, the extensible vi layer)
Other
627 stars 60 forks source link

Repeating surround does not surround the expected text #124

Closed olymk2 closed 6 years ago

olymk2 commented 6 years ago

when using . to repeat the last surrounded word it will not surround the correct with and will insert at the width of the first word you surrounded, see below example.

"word" "long"er word

This may be a limitation but stack overflow suggested it may also be a bug so thought I would report it.

https://emacs.stackexchange.com/questions/36046/evil-surround-repeat-varying-on-varying-width-text-possible?noredirect=1#comment56820_36046

edkolev commented 6 years ago

I can't reproduce. Could you give more details like which keys you press?

ninrod commented 6 years ago

cannot reproduce.

tried with ysiw".

olymk2 commented 6 years ago

I am using viws" to select the word in the cursor and surround it, followed by moving the cursor up or down and pressing . to repeat the last command.

using ysiw" actually works, can you explain it ? y is yank s surround i presume I in w word and quote for the surround, reading that it does not make as much sense as visual in word surround quote, why yank ?

ninrod commented 6 years ago

Ah, now I see why it does not work for you. Selection operations are not repeatable in vim keybindings. Actually there are people that say that beggining a vim command with v is an anti-pattern because you can not repeat it. Test on your own on an empty buffer. See that viWU and . does not repeat while gUiW and . repeats perfectly. It's just how vim works.

olymk2 commented 6 years ago

Okay thats great info thanks @ninrod, can you explain the combination ie whats happening on each key stroke it helps me internalize whats happening, still seems weird that it starts with y ?

edkolev commented 6 years ago

I'd recommend you complete vimtutor (cli tool, comes with vim)

ninrod commented 6 years ago

yes, vim tutor is a must. also, just type learning vim in youtube. there's loads of stuff there. Of special interest I'd recommend you pay close attention to text objects. Finally, this site is an excelent resource: http://vimcasts.org/