From 85750560a680907c50c1545abc4dd0e0b2452ff4 Mon Sep 17 00:00:00 2001 From: Sybrand Aarnoutse Date: Fri, 30 Oct 2020 20:25:01 +0100 Subject: [PATCH 01/18] Add delimiter for the `nix` language. (#442) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 5d32d38..0b1cff9 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -292,6 +292,7 @@ let s:delimiterMap = { \ 'newlisp': { 'left': ';' }, \ 'nginx': { 'left': '#' }, \ 'nimrod': { 'left': '#' }, + \ 'nix': { 'left': '#' }, \ 'nroff': { 'left': '\"' }, \ 'nsis': { 'left': '#' }, \ 'ntp': { 'left': '#' }, From 253eafd3a71ce2a48306fe4a7bdfc4208d0c2eb5 Mon Sep 17 00:00:00 2001 From: Wynell <65278392+uWynell@users.noreply.github.com> Date: Thu, 19 Nov 2020 12:25:03 +0300 Subject: [PATCH 02/18] Mention g:NERDCreateDefaultMappings in README.md (#445) --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5996286..f274b46 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,9 @@ Please see the vim help system for full documentation of all options: `:help ner Several settings can be added to your vimrc to change the default behavior. Some examples: ```vim +" Create default mappings +let g:NERDCreateDefaultMappings = 1 + " Add spaces after comment delimiters by default let g:NERDSpaceDelims = 1 @@ -103,6 +106,8 @@ let g:NERDToggleCheckAllLines = 1 ### Default mappings +> **Note:** You can turn off settings default mappings to provide your own from scratch (look at the [Settings list](#settings) above) + The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings): Most of the following mappings are for normal/visual mode only. The **|NERDCommenterInsert|** mapping is for insert mode only. From 3441a98b2d33e2d0a658c99ee0558f0474361e82 Mon Sep 17 00:00:00 2001 From: Priyansh Saxena Date: Tue, 1 Dec 2020 12:07:49 +0530 Subject: [PATCH 03/18] Add support for Rego (Open Policy Agent) (#446) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 0b1cff9..eeec642 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -351,6 +351,7 @@ let s:delimiterMap = { \ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'rebol': { 'left': ';' }, \ 'registry': { 'left': ';' }, + \ 'rego': { 'left': ';' }, \ 'remind': { 'left': '#' }, \ 'renpy': { 'left': '# ' }, \ 'resolv': { 'left': '#' }, From f02686f2f60fd9cfb18976f12d791c2663cf17c8 Mon Sep 17 00:00:00 2001 From: Cristiano De Michele Date: Thu, 3 Dec 2020 10:33:37 +0100 Subject: [PATCH 04/18] Fix alternative delimiter issue #425 (#440) Co-authored-by: Cristiano De Michele --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index eeec642..b3060bb 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -705,7 +705,7 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) "alternative delimiters (if THEY are) as the comment will be better and more "accurate with multipart delimiters let switchedDelims = 0 - if !s:Multipart() && g:NERDAllowAnyVisualDelims && s:AltMultipart() + if !s:Multipart() && !g:NERDAllowAnyVisualDelims && s:AltMultipart() let switchedDelims = 1 call s:SwitchToAlternativeDelimiters(0) endif From 119b99d1662113a588734e3666213d246e50900d Mon Sep 17 00:00:00 2001 From: Repon Kumar Roy Date: Fri, 11 Dec 2020 17:19:05 +0800 Subject: [PATCH 05/18] Add support for the jsonnet language (#450) Co-authored-by: Repon Kumar Roy --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index b3060bb..ab7817f 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -231,6 +231,7 @@ let s:delimiterMap = { \ 'jgraph': { 'left': '(*', 'right': '*)' }, \ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '' }, \ 'jproperties': { 'left': '#' }, + \ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jsp': { 'left': '<%--', 'right': '--%>' }, \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' }, \ 'kivy': { 'left': '#' }, From 7d2fb974a36b3c7773a90a749fcb92a40669e444 Mon Sep 17 00:00:00 2001 From: Rich Churcher Date: Tue, 12 Jan 2021 17:33:59 +1300 Subject: [PATCH 06/18] Add a note on binds for text object motions (#454) --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index f274b46..e606602 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,14 @@ Most of the following mappings are for normal/visual mode only. The **|NERDComme Uncomments the selected line(s). +## Motions + +While the plugin does not directly support motions, you can leverage its support for selections to do something very similar. For example, to add motions to toggle comments on the paragraph text object you could use: +```vim +nnoremap c} V}:call NERDComment('x', 'toggle') +nnoremap c{ V{:call NERDComment('x', 'toggle') +``` + ## Contributions This plugin was originally written in 2007 by [Martin Grenfell (@scrooloose)](https://github.com/scrooloose/). Lots of features and many of the supported filetypes have come from [community contributors](https://github.com/preservim/nerdcommenter/graphs/contributors). Since 2016 it has been maintained primarily by [Caleb Maclennan (@alerque)](https://github.com/alerque). Additional file type support, bug fixes, and new feature contributons are all welcome, please send them as Pull Requests on Github. If you can't contribute yourself please also feel free to open issues to report problems or request features. From 7be3292b8de5127a386bf20f1198704e90cf24e9 Mon Sep 17 00:00:00 2001 From: Tiger Nie Date: Tue, 19 Jan 2021 17:38:54 +0800 Subject: [PATCH 07/18] Add support for jsonc (#455) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index ab7817f..7ba6e9b 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -231,6 +231,7 @@ let s:delimiterMap = { \ 'jgraph': { 'left': '(*', 'right': '*)' }, \ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '' }, \ 'jproperties': { 'left': '#' }, + \ 'jsonc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jsonnet': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jsp': { 'left': '<%--', 'right': '--%>' }, \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' }, From 2955d669dcb597dc9ced04cf1ee776983053b15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20H=C3=BCbner?= Date: Wed, 27 Jan 2021 09:22:41 +0100 Subject: [PATCH 08/18] Fix leftAlt for filetype rmd (#458) --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 7ba6e9b..f5d8ac2 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -359,7 +359,7 @@ let s:delimiterMap = { \ 'resolv': { 'left': '#' }, \ 'rgb': { 'left': '!' }, \ 'rib': { 'left': '#' }, - \ 'rmd': { 'left': '', 'leftalt': '#' }, + \ 'rmd': { 'left': '', 'leftAlt': '#' }, \ 'robot': { 'left': '#' }, \ 'robots': { 'left': '#' }, \ 'rspec': { 'left': '#' }, From 898de2de1bf78c16768a188f5b1a26f6e3252fd1 Mon Sep 17 00:00:00 2001 From: John Flores <56614456+jnsf-cg@users.noreply.github.com> Date: Sat, 30 Jan 2021 22:41:13 -0800 Subject: [PATCH 09/18] Update rego comment to # (#459) --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index f5d8ac2..39ab035 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -353,7 +353,7 @@ let s:delimiterMap = { \ 'rc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'rebol': { 'left': ';' }, \ 'registry': { 'left': ';' }, - \ 'rego': { 'left': ';' }, + \ 'rego': { 'left': '#' }, \ 'remind': { 'left': '#' }, \ 'renpy': { 'left': '# ' }, \ 'resolv': { 'left': '#' }, From b83e9cdf835161b398e04e4c462103fd21801ee3 Mon Sep 17 00:00:00 2001 From: kevinhwang91 Date: Tue, 2 Feb 2021 15:29:10 +0800 Subject: [PATCH 10/18] fix: uncomment Lua in sexy mode with NERDCompactSexyComs=1 (#451) --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 39ab035..a692fe0 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -2153,7 +2153,7 @@ endfunction " Function: s:Esc(str) " Escapes all the tricky chars in the given string function s:Esc(str) - let charsToEsc = '*/\."&$+' + let charsToEsc = '*/\."&$+[]' return escape(a:str, charsToEsc) endfunction From 1c7b57608e653b55731d5971ba11c4c691b14c8c Mon Sep 17 00:00:00 2001 From: Bertold Sedlak <60078188+teaVeloper@users.noreply.github.com> Date: Thu, 18 Feb 2021 04:44:26 +0100 Subject: [PATCH 11/18] Add UC4 Filetype (#462) Add Support for UC4 Scripts as used by Automic Automation Engine See docs for details: https://docs.automic.com/documentation/webhelp/english/AWA/11.2/AE/11.2/All%20Guides/Content/ucabqx.htm --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index a692fe0..10a49db 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -450,6 +450,7 @@ let s:delimiterMap = { \ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' }, \ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'uc4': { 'left': '!' }, \ 'uil': { 'left': '!' }, \ 'upstart': { 'left': '#' }, \ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, From 16ecc429ec2792ba5c972f0a920dc14223b7bd4a Mon Sep 17 00:00:00 2001 From: Adrien Lemaire Date: Sat, 27 Feb 2021 18:25:37 +0900 Subject: [PATCH 12/18] Add neo4j cypher filetype (#464) Let nerdcommenter properly comment cypher files. * [extension recommendation](https://neo4j.com/docs/cypher-manual/current/styleguide/#cypher-styleguide-general-recommendations) * [comments syntax](https://neo4j.com/docs/cypher-manual/current/syntax/comments/) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 10a49db..b7d3b9a 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -121,6 +121,7 @@ let s:delimiterMap = { \ 'cucumber': { 'left': '#' }, \ 'cuda': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'cvs': { 'left': 'CVS:' }, + \ 'cypher': { 'left': '//' }, \ 'cython': { 'left': '# ', 'leftAlt': '#' }, \ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'dakota': { 'left': '#' }, From 6d0ab7dec9306fada667ea71edbb3da2b06a40ad Mon Sep 17 00:00:00 2001 From: Gabriel Nagy Date: Tue, 6 Apr 2021 09:57:40 +0300 Subject: [PATCH 13/18] Add hocon filetype (#465) Add support for commenting hocon files. [1] https://github.com/lightbend/config/blob/main/HOCON.md#comments --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index b7d3b9a..5e46feb 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -204,6 +204,7 @@ let s:delimiterMap = { \ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' }, \ 'hercules': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'hive': { 'left': '-- ' }, + \ 'hocon': { 'left': '//', 'leftAlt': '#' }, \ 'hog': { 'left': '#' }, \ 'hostsaccess': { 'left': '#' }, \ 'htmlcheetah': { 'left': '##' }, From d4855b233e950ae251021854bacd3a8300cc6c0f Mon Sep 17 00:00:00 2001 From: Nate Sire Date: Tue, 13 Apr 2021 00:37:51 -0400 Subject: [PATCH 14/18] Wrap installation blurbs in expandable summary/detail blocks --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index e606602..c3b3fa6 100644 --- a/README.md +++ b/README.md @@ -8,33 +8,55 @@ Comment functions so powerful—no comment necessary. ### Via Plugin Manager (Recommended) +
+ Vim Plug + #### [Vim-Plug](https://github.com/junegunn/vim-plug) 1. Add `Plug 'preservim/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart 3. Run `:PlugInstall` +
+ +
+ Vundle + #### [Vundle](https://github.com/VundleVim/Vundle.vim) or similar 1. Add `Plugin 'preservim/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart 3. Run `:BundleInstall` +
+ +
+ NeoBundle + #### [NeoBundle](https://github.com/Shougo/neobundle.vim) 1. Add `NeoBundle 'preservim/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart 3. Run `:NeoUpdate` +
+ +
+ Pathogen + #### [Pathogen](https://github.com/tpope/vim-pathogen) ```sh cd ~/.vim/bundle git clone https://github.com/preservim/nerdcommenter.git ``` +
### Manual Installation +
+ Unix + #### Unix (For Neovim, change `~/.vim/` to `~/.config/nvim/`.) @@ -45,7 +67,10 @@ curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \ curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \ https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/NERD_commenter.txt ``` +
+
+ Windows #### Windows (PowerShell) ```powershell @@ -56,6 +81,7 @@ $docsuri = 'https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc (New-Object Net.WebClient).DownloadFile($pluguri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\plugin\NERD_commenter.vim")) (New-Object Net.WebClient).DownloadFile($docsuri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\doc\NERD_commenter.txt")) ``` +
### Post Installation From b2642c8ed974866a13cc5eea14a37c25e40f2b59 Mon Sep 17 00:00:00 2001 From: Nate Sire Date: Tue, 13 Apr 2021 00:48:07 -0400 Subject: [PATCH 15/18] Add Directions for Vim 8+ Packages --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c3b3fa6..16811cc 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ git clone https://github.com/preservim/nerdcommenter.git ``` +
+ Vim 8+ Packages + + git clone https://github.com/preservim/nerdcommenter.git ~/.vim/pack/vendor/start/nerdcommenter +
+ ### Manual Installation
From d9366fc27cbc790355e08b7ca6aee182c55f2899 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 30 Apr 2021 12:31:10 +0300 Subject: [PATCH 16/18] Add filetype for bind-named (similar to named, used by some plugins) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 5e46feb..04598d1 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -91,6 +91,7 @@ let s:delimiterMap = { \ 'bc': { 'left': '#' }, \ 'bib': { 'left': '//' }, \ 'bindzone': { 'left': ';' }, + \ 'bind-named': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'blade': { 'left': '{{--', 'right': '--}}' }, \ 'bst': { 'left': '%' }, \ 'btm': { 'left': '::' }, From ab475e1325ad6eaec15a3113f201a4e4a3ee2811 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 30 Apr 2021 12:31:25 +0300 Subject: [PATCH 17/18] Add filetype for exim configs --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 04598d1..9582ca9 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -157,6 +157,7 @@ let s:delimiterMap = { \ 'erlang': { 'left': '%', 'leftAlt': '%%' }, \ 'eruby': { 'left': '<%#', 'right': '%>', 'leftAlt': '' }, \ 'esmtprc': { 'left': '#' }, + \ 'exim': { 'left': '#' }, \ 'expect': { 'left': '#' }, \ 'exports': { 'left': '#' }, \ 'factor': { 'left': '! ', 'leftAlt': '!# ' }, From a5d1663185bee20bfb120c9ab212144444514982 Mon Sep 17 00:00:00 2001 From: Jaehwang Jerry Jung Date: Sat, 29 May 2021 20:00:30 +0900 Subject: [PATCH 18/18] Fix multibyte character bug in block comment (#469) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NERDCommenterComment using block comment on visual block whose last char is unicode breaks up the unicode char. Example: a가 → /* a */<80> To fix this, add the character's byte length to the index used for chopping the right part of the text block to be commented. --- plugin/NERD_commenter.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 9582ca9..17b9d43 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -750,7 +750,9 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) if s:Multipart() "stick the right delimiter down - let theLine = strpart(theLine, 0, rSide+strlen(leftSpaced)) . rightSpaced . strpart(theLine, rSide+strlen(leftSpaced)) + "byte idx of the char next to the last char = (byte idx of last char + 1) + (last char byte len) - 1 + let rIndex = (rSide+strlen(leftSpaced)) + strlen(strcharpart(strpart(theLine, rSide+strlen(leftSpaced)-1), 0, 1)) - 1 + let theLine = strpart(theLine, 0, rIndex) . rightSpaced . strpart(theLine, rIndex) let firstLeftDelim = s:FindDelimiterIndex(s:Left(), theLine) let lastRightDelim = s:LastIndexOfDelim(s:Right(), theLine)