Help with a custom definition for Find/Delete/Replace - Add already working #408
-
I have created this pattern which I have been absolutely loving: local function get_matching_delims(string_left_delimiter, string_right_delimiter)
local prompt = "Enter the left delimiter to be surrounded by '"
.. string_left_delimiter
.. " "
.. string_right_delimiter
.. "' (Can add multiple, i.e., 'Array Gd': "
local base_delimiter = config.get_input(prompt)
-- Replace spaces with "the left delimiter"
local left_delimiter = string.gsub(base_delimiter, " ", string_left_delimiter)
local right_delimiter = string_right_delimiter
-- Ballance any added "left delimiters"
for char in string.gmatch(left_delimiter, ".") do
if char == string_left_delimiter then right_delimiter = right_delimiter .. string_right_delimiter end
end
left_delimiter = left_delimiter .. string_left_delimiter
return { { left_delimiter }, { right_delimiter } }
end
...
surrounds = {
["("] = {
add = function() return get_matching_delims("(", ")") end,
find = function() end,
delete = function() end,
},
} This allows me to do normal parentheses surround with However, I don't really know how best to extend this to the find/delete or whatever is needed for me to do I've looked at the docs but couldn't get any traction. I essentially need my |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I'm not exactly sure what you are trying to do here (specifically not sure what you mean by |
Beta Was this translation helpful? Give feedback.
Ah yes, in the
delete
/change.target
strings you should see exactly one pair of escaped parens (i.e.%(
and%)
). Replace each of the escaped parens with its respective angle bracket, i.e.%(
→<
and%)
→>
.