Add the missing gco, gcO, and gcA comment insertion mappings without replacing your comment operator.
Neovim has built-in gc and gcc mappings, and mini.comment provides a compact toggle/comment textobject implementation. Neither one ships gco, gcO, or gcA.
tiny-comment.nvim fills only that gap:
gcoinserts a commented line below and enters Insert modegcOinserts a commented line above and enters Insert modegcAappends a comment at the end of the current line and enters Insert mode[count]gcoand[count]gcOinsert multiple commented lines
- Neovim 0.10+
{
"so1ve/tiny-comment.nvim",
}With the default setup, the plugin registers the mappings automatically when it loads:
gco
gcO
gcAUse it next to Neovim's built-in comments:
-- Neovim keeps these:
-- gc, gcc
-- tiny-comment.nvim adds these:
-- gco, gcO, gcAOr next to mini.comment; it keeps owning gc and gcc while tiny-comment only adds the insertion maps:
require("mini.comment").setup()
require("tiny-comment").setup()require("tiny-comment").setup({
mappings = {
below = "gco",
above = "gcO",
eol = "gcA",
},
})Registers the configured mappings.
require("tiny-comment").setup({})Insert a commented line below the current line and enter Insert mode.
require("tiny-comment").insert_below()Insert a commented line above the current line and enter Insert mode.
require("tiny-comment").insert_above()Append a comment to the end of the current line and enter Insert mode.
require("tiny-comment").insert_eol()tiny-comment.nvim intentionally does not implement comment toggling. Use Neovim's built-in comment mappings or mini.comment for gc, gcc, Visual gc, and comment textobjects.
tiny-comment.nvim uses the current buffer's commentstring, with a small Tree-sitter-aware fallback for injected languages.
stylua lua plugin tests
nvim --headless -u NONE -l tests/tiny-comment_spec.lua