Skip to content

JavaScript Template String Expression Surround #266

Answered by kylechui
willdavidow asked this question in Q&A
Discussion options

You must be logged in to vote

There currently isn't a way to detect what the nearest surrounding pair is, and it seems quite complicated to expose this information to the end user as a part of the plugin itself. However, here are some potential workarounds:

  • There's the q alias for targeting the nearest surrounding pair of quotes; your first case could be handled by first running csq` (change surrounding quotes to `) then yziws.
  • I might recommend you create a second surround key like S that adds { "`${", "}`" } to the buffer to handle your second case

I think a better/marginally more complicated way is for you to use Tree-sitter to detect whether or not the node located at the cursor is a string, then use that inform…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@kylechui
Comment options

@willdavidow
Comment options

@willdavidow
Comment options

@kylechui
Comment options

@willdavidow
Comment options

Answer selected by willdavidow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants