How to remove inserted text in $1? #1143
-
Hello, I'm not sure if I'm going about this the right way by using --[=============== SMALL HEADING =================]
--[============================= LARGE HEADING ==============================] However, when I am done with my snippet it leaves the inserted text -- [============================= Large Heading =============================]Large Heading If possible I would like to avoid using vimscript to do line manipulation. How can I accomplish this? -- [============================= Large Heading =============================]
$0 Here is the code: s(
"s",
sn(1, {
f(function(args)
local title = args[1][1]
local cs = vim.bo.commentstring:gsub("%%s", "")
-- local pad = math.floor((73 - string.len(title) - 2) / 2)
local pad = (73 - string.len(title) - 2) / 2
return cs.."["..string.rep("=", pad ).." "..title.." "..string.rep("=", pad).."]"
end, { 1 }),
i(1, "Insert Titile"),
i(0),
})
), Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think I'm going about it the wrong way, ideally you want to calculate the pad with |
Beta Was this translation helpful? Give feedback.
I think I'm going about it the wrong way, ideally you want to calculate the pad with
f()
thenI(1,"insert title")
thenf()
, that's how it's done with the 3 line box... At that point no need to delete anything cause you calculate the pad on both sides accordingto the insert.