How to escape the block using surround? #2154
-
|
As example, how do i go from to just |
Beta Was this translation helpful? Give feedback.
Answered by
echasnovski
Dec 6, 2025
Replies: 1 comment 2 replies
-
|
Could you please elaborate on what you mean by "escape the block"? For 'mini.surround' to be a good candidate to achieve this, there needs to be a way to phrase this like "find left+right parts of surrounding and delete them". |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am afraid "reliable" and "easy" here are a bit at odds with each other.
The most reliable way would be to use tree-sitter based surrounding. For this particular case, it seems to require custom tree-sitter queries.
Here is what I've got mostly working:
Write custom tree-sitter query with two captures: one for the outside (text + left surrounding + right surrounding) and one for the inside (only text without surroundings). For this particular case, put the following code into '~/.config/nvim/after/queries/go/textobjects.scm':
;; extends (if_statement consequence: (block (statement_list) @if.inner )) @if.outerThis query was created by…