Repository navigation
How to delete empty lines after deleting html tags #451
|
removing the html tags leaves empty lines: Before <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
</body>
</html>the cursor being on After <!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="css/style.css" rel="stylesheet">
<body>
</body>
</html>Expected <!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="css/style.css" rel="stylesheet">
<body>
</body>
</html> |
Replies: 2 comments 1 reply
|
The empty lines are not deleted by default, you would need to overwrite the |
|
Building on @kylechui’s note: by default Default "^(%b<>)().-(%b<>)()$"Override it so the left/right selections also consume surrounding whitespace (same idea as how require("nvim-surround").setup({
surrounds = {
["t"] = {
delete = "^(%b<>%s*)().-(%s*%b<>)()$",
},
["T"] = {
delete = "^(%b<>%s*)().-(%s*%b<>)()$",
},
},
})With that, <!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="css/style.css" rel="stylesheet">
<body>
</body>
</html>Note: this is aggressive about whitespace. For inline tags like Quick one-off without config: after If this solves it for you, please mark this as the answer — thanks! |
Building on @kylechui’s note: by default
dstonly removes the tags themselves, not the whitespace/newlines around them. That’s why you get empty lines.Default
deletepattern fortis:"^(%b<>)().-(%b<>)()$"Override it so the left/right selections also consume surrounding whitespace (same idea as how
(delete includes spaces):With that,
dston<head>in your example should produce: