Skip to content

Adding comments with signature using :ab and :iabbrev #283

Answered by numToStr
rameshsanth asked this question in Q&A
Discussion options

You must be logged in to vote

I am not that familiar with how abbreviations family of commands works but I quickly checked, and I believe this is what you want:

local api = require("Comment.api")

-- Add comment at end of the line with "signature"
function _G.Sign()
    api.insert.linewise.eol()
    vim.api.nvim_put({ "--my_signature" }, "c", true, true)
end

vim.cmd("iabbr msb <C-o>:lua Sign()<CR>")

NOTE - Currently there is a bug with eol where a is inserted at the end.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rameshsanth
Comment options

@numToStr
Comment options

Answer selected by rameshsanth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants