Skip to content

Latest commit

 

History

History
129 lines (103 loc) · 5.15 KB

mini-comment.md

File metadata and controls

129 lines (103 loc) · 5.15 KB

GitHub license

Fast and familiar per-line commenting

See more details in help file.

This is a part of mini.nvim library. See its repository page to learn about common design principles and configuration recipes.

If you want to help this project grow but don't know where to start, check out contributing guides or leave a Github star for 'mini.nvim' project.

Demo

demo-comment.mp4

Features

  • Commenting in Normal mode respects v:count and is dot-repeatable.
  • Comment structure is inferred from 'commentstring'.
  • Handles both tab and space indenting (but not when they are mixed).
  • Allows custom hooks before and after successful commenting.

Installation

There are two branches to install from:

  • main (default, recommended) will have latest development version of plugin. All changes since last stable release should be perceived as being in beta testing phase (meaning they already passed alpha-testing and are moderately settled).
  • stable will be updated only upon releases with code tested during public beta-testing phase in main branch.

Here are code snippets for some common installation methods (use only one):

Branch Code snippet
Main use 'echasnovski/mini.nvim'
Stable use { 'echasnovski/mini.nvim', branch = 'stable' }
Branch Code snippet
Main Plug 'echasnovski/mini.nvim'
Stable Plug 'echasnovski/mini.nvim', { 'branch': 'stable' }

Important: don't forget to call require('mini.comment').setup() to enable its functionality.

Note: if you are on Windows, there might be problems with too long file paths (like error: unable to create file <some file name>: Filename too long). Try doing one of the following:

  • Enable corresponding git global config value: git config --system core.longpaths true. Then try to reinstall.
  • Install plugin in other place with shorter path.

Default config

-- No need to copy this inside `setup()`. Will be used automatically.
{
  -- Module mappings. Use `''` (empty string) to disable one.
  mappings = {
    -- Toggle comment (like `gcip` - comment inner paragraph) for both
    -- Normal and Visual modes
    comment = 'gc',

    -- Toggle comment on current line
    comment_line = 'gcc',

    -- Define 'comment' textobject (like `dgc` - delete whole comment block)
    textobject = 'gc',
  },
  -- Hook functions to be executed at certain stage of commenting
  hooks = {
    -- Before successful commenting. Does nothing by default.
    pre = function() end,
    -- After successful commenting. Does nothing by default.
    post = function() end,
  },
}

Similar plugins