Skip to content
Discussion options

You must be logged in to vote

Building on @kylechui’s note: by default dst only removes the tags themselves, not the whitespace/newlines around them. That’s why you get empty lines.

Default delete pattern for t is:

"^(%b<>)().-(%b<>)()$"

Override it so the left/right selections also consume surrounding whitespace (same idea as how ( delete includes spaces):

require("nvim-surround").setup({
  surrounds = {
    ["t"] = {
      delete = "^(%b<>%s*)().-(%s*%b<>)()$",
    },
    ["T"] = {
      delete = "^(%b<>%s*)().-(%s*%b<>)()$",
    },
  },
})

With that, dst on <head> in your example should produce:

<!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mortezadadgar
Comment options

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