馃 my neovim config:)
1-- https://github.com/echasnovski/nvim/blob/0a87022921d2e2a95fb987c4f11fc4804b57d6f9/plugin/21_functions.lua#L23
2
3vim.keymap.set("n", "<Plug>(ivy-insert-section)", function()
4 local symbol = "="
5 local total_width = vim.o.textwidth > 0 and vim.o.textwidth or 79
6
7 -- Insert template: 'commentstring' but with '%s' replaced by section symbols
8 local comment_string = vim.bo.commentstring
9 local comment_str_len = #comment_string:format("")
10 local content = string.rep(symbol, total_width - comment_str_len)
11 local section_template = comment_string:format(content)
12 local okn = vim.fn.append(vim.fn.line("."), { section_template })
13 if okn == 1 then
14 return
15 end
16
17 -- Enable Replace mode in appropriate place
18 local inner_start = comment_string:find("%%s")
19 vim.fn.cursor(vim.fn.line(".") + 1, inner_start)
20 vim.cmd([[startreplace]])
21end)