emacs-evil / evil-surround

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

Using surround to manipulate quotes is broken when emacs doesn't think you're in a quoted string #56

Open rolandcrosby opened 9 years ago

rolandcrosby commented 9 years ago

In this text file, with your cursor in the middle of the word 'this':

5'11" tall
change "this" word

attempting to manipulate the surrounding quotes (ds", cs", etc) returns a "No quoted string found" error. In Vim with surround installed, the quotes are correctly detected and manipulated.

I believe this is due to Evil's quote textobject using native Emacs quote parsing, per this thread. Also per that thread, it sounds like Evil itself is not going to change the way quote textobjects are parsed, so a change to make surround behave normally would have to be made in evil-surround itself.

ninrod commented 7 years ago

Yes this is related to #92. I think evil-surround should enclose it's scope only inside a line, not multlinewise because it get's hard to know if you are writing a multiline string or not.

ninrod commented 6 years ago

@rolandcrosby, this is really hard for evil-surround to deal with. vim surround actually displays disparate behaviour in this regard. Let's take this as an example(cursor on |):

5'11( tall
ch|ange )this' word

ds( will kill the parenthesis in vim-surround. Now if we want to kill quotes in vim-surround with ds', it will not work because they are in different lines. I'm not sure if vim-surround is right. I think evil-surround is right in this case because it treats all cases equally: multilinewise.

I'm not 100% sure of what to do in this case but I'm inclined to leave it as it is.

ninrod commented 6 years ago

what do you think @justbur, @edkolev, @wasamasa and @TheBB?

actionshrimp commented 6 years ago

Interestingly this seems to happen even when there are no literal surrounding characters due (I assume) to the native quote parsing.

With this YAML snippet:

args:
  - '-c'
  - |
    git config --global user.email "dave@email.com"
    git config --global user.name "dave"

in yaml-mode, the two lines after the pipe count as quoted, and with the cursor inside the email quotes, doing e.g. di" gives the No quoted string found message.

However if you switch to text-mode, di" works as expected.

ninrod commented 6 years ago

@actionshrimp I think that happens because yaml-mode defines a different syntax table for quoted stuff.

actionshrimp commented 6 years ago

Ah I just realised this is related to evil text-objects rather than surround specifically (I was actually trying to do some surround related operations which sent me off in the wrong place). Sorry for the noise!

jvtrigueros commented 3 years ago

@actionshrimp I just hit this exact issue in YAML, did you have a workaround for this? Don't mean to hijack, just working in YAML so much and I don't know where else to look.