Fork me on GitHub
#emacs
<
2019-04-17
>
hipster coder18:04:05

anyone know an emacs command to replace single quotes around a text/string with double quotes?

hipster coder22:04:29

spacemacs, evil mode

theeternalpulse22:04:27

if you place your cursor anywhere on or inside the quotes you can do c s ' "

😎 4
theeternalpulse22:04:40

this is with evil-surround which spacemacs should have

theeternalpulse22:04:58

mnemonically it means "change surrounding single quote to double quote"

theeternalpulse22:04:18

you can also type '.' after your cursor is on another one and it will repeat the sequence

hipster coder22:04:17

omg, that’s so cool. it works. Space macs rocks.

theeternalpulse22:04:31

hehe, you mean "emacs rocks" but yes, spacemacs adds a lot of the best packages, makes it look like they made it themselves 🙂.

theeternalpulse22:04:50

also evil-surround lets you define your own surround regexps

theeternalpulse22:04:02

also, it seems to recognize ' and " when you do c s '

theeternalpulse22:04:12

so you never have to press shift to match the double

hipster coder22:04:51

what’s a good use case for using regex to replace surrounding delimeters? I am trying to learn more refactoring tricks

theeternalpulse23:04:44

Depends on the language, I think evil-surround has the basics for most languages, but if you want custom ones you can add them. Maybe adding common surrounds for tags for example, though I think they have those set up already. I haven't added any, but there's a section in the docs that could shed light

theeternalpulse23:04:02

maybe you want to delete a surrounding function and replace with an assignment

theeternalpulse23:04:42

in the case of js

richiardiandrea18:04:45

@nathantech2005 I use string-edit for this kind of things

💯 4
❤️ 4