Adding comments with signature using :ab
and :iabbrev
#283
-
This belongs to both Ideas and Q&A section I feel this can be a very useful feature if integrated with this plugin. I have below vi commands to insert comments with signature in them..
As you can see The issue is, this set needs to be replicated for each type of file. C/Python/Shell/ etc.. Plus this is VIM commands. Is there a way to do this programmatically using the Comment plugin ? I started with something as below which adds comment at the end of the line.. but I don't know how to tie this with "iabbr" -- Add comment at end of the line with "signature"
local api = require('Comment.api')
local config = require('Comment.config'):get()
local signature = {"--my_signature"}
api.insert.linewise.eol(config)
vim.api.nvim_put(signature, 'c', true, true) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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>")
|
Beta Was this translation helpful? Give feedback.
I am not that familiar with how abbreviations family of commands works but I quickly checked, and I believe this is what you want: