From c51f5992b256e4a5ec0daff8c4ca2c0b01964a0e Mon Sep 17 00:00:00 2001 From: Aluriak Date: Sat, 10 Sep 2016 01:20:29 +0200 Subject: [PATCH 01/21] add support for turtle (.ttl) files --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 8b8c297..c8f8970 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -422,6 +422,7 @@ let s:delimiterMap = { \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tsscl': { 'left': '#' }, \ 'tssgm': { 'left': "comment = '", 'right': "'" }, + \ 'ttl': { 'left': '#' }, \ 'tup': { 'left': '#' }, \ 'twig': { 'left': '{#', 'right': '#}' }, \ 'txt2tags': { 'left': '%' }, From c321b3460bc8b6172ef0c5045d8f862c8cb9f2d1 Mon Sep 17 00:00:00 2001 From: Komeji Koishi Date: Thu, 5 Jan 2017 16:33:29 +0400 Subject: [PATCH 02/21] Added filetype 'renpy' support. Renpy is an extension of python syntax and it uses '#' comments. --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index e8e1af9..0607ae5 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -349,6 +349,7 @@ let s:delimiterMap = { \ 'rebol': { 'left': ';' }, \ 'registry': { 'left': ';' }, \ 'remind': { 'left': '#' }, + \ 'renpy': { 'left': '# ', 'leftAlt': '#' }, \ 'resolv': { 'left': '#' }, \ 'rgb': { 'left': '!' }, \ 'rib': { 'left': '#' }, From d4548ebb0cd10f80b417e0129d0325da26c1c567 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 7 Nov 2017 10:11:26 +0300 Subject: [PATCH 03/21] Fix implementation of renpy to not include python hack --- 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 0607ae5..d81c830 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -349,7 +349,7 @@ let s:delimiterMap = { \ 'rebol': { 'left': ';' }, \ 'registry': { 'left': ';' }, \ 'remind': { 'left': '#' }, - \ 'renpy': { 'left': '# ', 'leftAlt': '#' }, + \ 'renpy': { 'left': '# ' }, \ 'resolv': { 'left': '#' }, \ 'rgb': { 'left': '!' }, \ 'rib': { 'left': '#' }, From 3e99b39f4fbbb90f97d7de390d9bfe9cdf2208b3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 7 Nov 2017 10:37:56 +0300 Subject: [PATCH 04/21] Add sshconfig filetype to complement sshdconfig Mentioned in #313 --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 09c8444..3d9cf63 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -408,6 +408,7 @@ let s:delimiterMap = { \ 'sqr': { 'left': '!' }, \ 'squid': { 'left': '#' }, \ 'ss': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' }, + \ 'sshconfig': { 'left': '#' }, \ 'sshdconfig': { 'left': '#' }, \ 'st': { 'left': '"' }, \ 'stan': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, From fd61bc71f64c8accf86f06c633fd19b205efa85b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 7 Nov 2017 10:46:22 +0300 Subject: [PATCH 05/21] Udate version and date strings --- plugin/NERD_commenter.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 3d9cf63..fb8a9df 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -3,8 +3,8 @@ " Description: vim global plugin that provides easy code commenting " Author: Martin Grenfell " Maintainer: Caleb Maclennan -" Version: 2.4.0 -" Last Change: Tue May 24 14:03:29 EEST 2016 +" Version: 2.5.1 +" Last Change: Tue Nov 7 10:45:53 +03 2017 " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You From af8bb4258d6767e35b42dc3071abd6574a3f665c Mon Sep 17 00:00:00 2001 From: Alec Shaw Date: Tue, 26 Dec 2017 08:02:19 +0000 Subject: [PATCH 06/21] Add support for Praat scripting language (#316) [Praat][1] is a program for phonetics research which has a scripting interface. [1]: http://www.fon.hum.uva.nl/praat/ --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index fb8a9df..86f0120 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -335,6 +335,7 @@ let s:delimiterMap = { \ 'povini': { 'left': ';' }, \ 'ppd': { 'left': '%' }, \ 'ppwiz': { 'left': ';;' }, + \ 'praat': { 'left': '#' }, \ 'privoxy': { 'left': '#' }, \ 'processing': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'prolog': { 'left': '%', 'leftAlt': '/*', 'rightAlt': '*/' }, From ff3d8d7d7cae2b64ad9c83c07f461f5115b2b7d6 Mon Sep 17 00:00:00 2001 From: tlsvc <6399789+tlsvc@users.noreply.github.com> Date: Sat, 13 Jan 2018 09:47:04 +0100 Subject: [PATCH 07/21] Add support for ANSYS Parametric Design Language (apdl) (#317) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 86f0120..c777c20 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -82,6 +82,7 @@ let s:delimiterMap = { \ 'ansible': { 'left': '#' }, \ 'apache': { 'left': '#' }, \ 'apachestyle': { 'left': '#' }, + \ 'apdl': { 'left': '!' }, \ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' }, \ 'armasm': { 'left': ';' }, \ 'asciidoc': { 'left': '//' }, From 2f973bd4fa009fe852b1c1c6f025bf38742a8b1c Mon Sep 17 00:00:00 2001 From: Sean Date: Fri, 2 Feb 2018 17:56:54 +0800 Subject: [PATCH 08/21] Fix Markdown formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd7eec0..2d464ad 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Comment functions so powerful—no comment necessary. 1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart -3. Run `:NeoUpdate`` +3. Run `:NeoUpdate` #### [Pathogen](https://github.com/tpope/vim-pathogen) From 670dba1bb53bc025173920b8066595074208fbe0 Mon Sep 17 00:00:00 2001 From: dandersson Date: Wed, 7 Feb 2018 10:19:12 +0100 Subject: [PATCH 09/21] Add support for Robot Framework files (#323) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index c777c20..704da0a 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -360,6 +360,7 @@ let s:delimiterMap = { \ 'rgb': { 'left': '!' }, \ 'rib': { 'left': '#' }, \ 'rmd': { 'left': '#' }, + \ 'robot': { 'left': '#' }, \ 'robots': { 'left': '#' }, \ 'rspec': { 'left': '#' }, \ 'ruby': { 'left': '#', 'leftAlt': '=begin', 'rightAlt': '=end' }, From e679d8a34193d1ac93b98ed792cdde7c9b1104a1 Mon Sep 17 00:00:00 2001 From: Jiaobuzuji Date: Sat, 3 Mar 2018 20:16:47 +0800 Subject: [PATCH 10/21] Add support for 'sdc' filetype (#327) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 704da0a..1591449 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -375,6 +375,7 @@ let s:delimiterMap = { \ 'scons': { 'left': '#' }, \ 'scsh': { 'left': ';' }, \ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'sdc': { 'left': '#' }, \ 'sed': { 'left': '#' }, \ 'sgmldecl': { 'left': '--', 'right': '--' }, \ 'sgmllnx': { 'left': '' }, From 9a32fd2534427f7a1dcfe22e9c0ea6b67b6dbe78 Mon Sep 17 00:00:00 2001 From: fcying Date: Thu, 21 Jun 2018 16:06:22 +0800 Subject: [PATCH 11/21] Add NERDToggleCheckAllLines option to NERDCommenterToggle (#334) --- README.md | 3 +++ doc/NERD_commenter.txt | 12 ++++++++++++ plugin/NERD_commenter.vim | 26 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2d464ad..a64b068 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,9 @@ let g:NERDCommentEmptyLines = 1 " Enable trimming of trailing whitespace when uncommenting let g:NERDTrimTrailingWhitespace = 1 + +" Enable NERDCommenterToggle to check all selected lines is commented or not +let g:NERDToggleCheckAllLines = 1 ``` ### Default mappings diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index d37507a..daf8b96 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -488,6 +488,9 @@ change the filetype back: > one of 'none', 'left', 'start', or 'both'. +|'NERDToggleCheckAllLines'| Enable NERDCommenterToggle to check + all selected lines is commented or not. + ------------------------------------------------------------------------------ 4.3 Options details *NERDComOptionsDetails* @@ -800,6 +803,15 @@ When this option is set to 1, comments are nested automatically. That is, if you hit ||cc on a line that is already commented it will be commented again. +------------------------------------------------------------------------------ + *'NERDToggleCheckAllLines'* +Values: 0 or 1. +Default 0. + +When this option is set to 1, NERDCommenterToggle will check all selected line, +if there have oneline not be commented, then comment all lines. + + ------------------------------------------------------------------------------ 3.3 Default delimiter customisation *NERDComDefaultDelims* diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 1591449..a4ada45 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -65,6 +65,7 @@ call s:InitVariable("g:NERDRPlace", "<]") call s:InitVariable("g:NERDSpaceDelims", 0) call s:InitVariable("g:NERDDefaultAlign", "none") call s:InitVariable("g:NERDTrimTrailingWhitespace", 0) +call s:InitVariable("g:NERDToggleCheckAllLines", 0) let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" @@ -1258,12 +1259,29 @@ function! NERDComment(mode, type) range endtry elseif a:type ==? 'Toggle' - let theLine = getline(firstLine) - - if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) - call s:UncommentLines(firstLine, lastLine) + if g:NERDToggleCheckAllLines ==# 0 + let theLine = getline(firstLine) + if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + call s:UncommentLines(firstLine, lastLine) + else + call s:CommentLinesToggle(forceNested, firstLine, lastLine) + endif else + let l:commentAllLines = 0 + for i in range(firstLine, lastLine) + let theLine = getline(i) + " if have one line no comment, then comment all lines + if !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + let l:commentAllLines = 1 + break + else + endif + endfor + if l:commentAllLines ==# 1 call s:CommentLinesToggle(forceNested, firstLine, lastLine) + else + call s:UncommentLines(firstLine, lastLine) + endif endif elseif a:type ==? 'Minimal' From f9dd87271a7147d82c6cf20071478e6d8019c3e8 Mon Sep 17 00:00:00 2001 From: Zachary Churchill Date: Fri, 27 Jul 2018 23:52:07 -0400 Subject: [PATCH 12/21] Swap default comment style to be more idiomatic of haskell (#343) See discussion at https://github.com/scrooloose/nerdcommenter/pull/343 --- 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 a4ada45..ee827cd 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -206,7 +206,7 @@ let s:delimiterMap = { \ 'h': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'haml': { 'left': '-#', 'leftAlt': '/' }, \ 'handlebars': { 'left': '{{!-- ', 'right': ' --}}' }, - \ 'haskell': { 'left': '{-', 'right': '-}', 'nested': 1, 'leftAlt': '--', 'nestedAlt': 1 }, + \ 'haskell': { 'left': '--', 'nested': 0, 'leftAlt': '{-', 'rightAlt': '-}', 'nestedAlt': 1 }, \ 'haxe': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'hb': { 'left': '#' }, \ 'hbs': { 'left': '{{!-- ', 'right': ' --}}' }, From fdf950f20b3907c6a6fa0bc5c7ac0aeb567841dd Mon Sep 17 00:00:00 2001 From: keysen Date: Tue, 31 Jul 2018 19:29:13 +0200 Subject: [PATCH 13/21] Fix ruby comments, totally broken with =begin and =end (#340) --- 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 ee827cd..614b9d2 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -364,7 +364,7 @@ let s:delimiterMap = { \ 'robot': { 'left': '#' }, \ 'robots': { 'left': '#' }, \ 'rspec': { 'left': '#' }, - \ 'ruby': { 'left': '#', 'leftAlt': '=begin', 'rightAlt': '=end' }, + \ 'ruby': { 'left': '#' }, \ 'rust': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'sa': { 'left': '--' }, \ 'samba': { 'left': ';', 'leftAlt': '#' }, From d24868bc85de599ee2424ca93aa5f6991bd3128c Mon Sep 17 00:00:00 2001 From: Maarten van der Hoef Date: Mon, 3 Dec 2018 14:22:57 +0100 Subject: [PATCH 14/21] Terraform replacing Transcript File (#350) --- 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 614b9d2..31ea0d5 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -431,7 +431,7 @@ let s:delimiterMap = { \ 'tex': { 'left': '%' }, \ 'texinfo': { 'left': "@c " }, \ 'texmf': { 'left': '%' }, - \ 'tf': { 'left': ';' }, + \ 'tf': { 'left': '#' }, \ 'tidy': { 'left': '#' }, \ 'tli': { 'left': '#' }, \ 'tmux': { 'left': '#' }, From 371e4d0e099abb86a3016fefd1efae28a4e13856 Mon Sep 17 00:00:00 2001 From: glegodais Date: Wed, 26 Dec 2018 12:11:50 +0100 Subject: [PATCH 15/21] Add support for Faust (#354) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 31ea0d5..6db80e4 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -172,6 +172,7 @@ let s:delimiterMap = { \ 'exports': { 'left': '#' }, \ 'factor': { 'left': '! ', 'leftAlt': '!# ' }, \ 'fancy': { 'left': '#' }, + \ 'faust': { 'left': '//' }, \ 'fgl': { 'left': '#' }, \ 'focexec': { 'left': '-*' }, \ 'form': { 'left': '*' }, From 3427b2f4ef5f28c9886b7fed54eb9b1cd417fbdf Mon Sep 17 00:00:00 2001 From: MeNsaaH Date: Mon, 4 Feb 2019 10:13:20 +0100 Subject: [PATCH 16/21] updated Django comments (#359) * updated Django comments * Adding alternate comments for django --- plugin/NERD_commenter.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 6db80e4..46a78b3 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -144,7 +144,7 @@ let s:delimiterMap = { \ 'desktop': { 'left': '#' }, \ 'dhcpd': { 'left': '#' }, \ 'diff': { 'left': '#' }, - \ 'django': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'django': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'dns': { 'left': ';' }, \ 'docbk': { 'left': '' }, \ 'dockerfile': { 'left': '#' }, @@ -216,7 +216,7 @@ let s:delimiterMap = { \ 'hog': { 'left': '#' }, \ 'hostsaccess': { 'left': '#' }, \ 'htmlcheetah': { 'left': '##' }, - \ 'htmldjango': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'htmldjango': { 'left': '{% comment %}', 'right': '{% endcomment %}', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'htmlos': { 'left': '#', 'right': '/#' }, \ 'hxml': { 'left': '#' }, \ 'hyphy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, From 5ac43900e91291cf3045c3858db0836d70f5ee12 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 14 Feb 2019 09:48:49 +0300 Subject: [PATCH 17/21] Strip trailing whitespace --- 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 46a78b3..918fbb6 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -172,7 +172,7 @@ let s:delimiterMap = { \ 'exports': { 'left': '#' }, \ 'factor': { 'left': '! ', 'leftAlt': '!# ' }, \ 'fancy': { 'left': '#' }, - \ 'faust': { 'left': '//' }, + \ 'faust': { 'left': '//' }, \ 'fgl': { 'left': '#' }, \ 'focexec': { 'left': '-*' }, \ 'form': { 'left': '*' }, From 5100f47542cb9cab120f172816471e6c3e242278 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 14 Feb 2019 09:50:24 +0300 Subject: [PATCH 18/21] Add kivy file format, fixes #361 --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 918fbb6..c787a0c 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -242,6 +242,7 @@ let s:delimiterMap = { \ 'jproperties': { 'left': '#' }, \ 'jsp': { 'left': '<%--', 'right': '--%>' }, \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' }, + \ 'kivy': { 'left': '#' }, \ 'kix': { 'left': ';' }, \ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'lace': { 'left': '--' }, From f46226bcd679a2d656b3179c54cc6b88f1db3b27 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 7 Mar 2019 12:00:42 +0300 Subject: [PATCH 19/21] Remove apparently bogus filetype I can't find any record of this being a legitimate filetype. It isn't in vim or nvim's filetype detection system and nothing comes up in search. If it's legit somebody can complain and we'll add it back, but it seems likely this was left over from a fat-fingered mistake during the initial development of the plugin. Fixes #363 --- plugin/NERD_commenter.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index c787a0c..60c0e31 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -284,7 +284,6 @@ let s:delimiterMap = { \ 'mkd': { 'left': '' }, \ 'mma': { 'left': '(*', 'right': '*)' }, \ 'model': { 'left': '$', 'right': '$' }, - \ 'moduala.': { 'left': '(*', 'right': '*)' }, \ 'modula2': { 'left': '(*', 'right': '*)' }, \ 'modula3': { 'left': '(*', 'right': '*)' }, \ 'molpro': { 'left': '!' }, From 67950d4b5d2e78733ab085a57c897c711e5eb2dc Mon Sep 17 00:00:00 2001 From: Lane Date: Wed, 17 Apr 2019 14:49:38 +0800 Subject: [PATCH 20/21] Make g:NERDToggleCheckAllLines not check blank/whitespace-only lines (#355) --- plugin/NERD_commenter.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 60c0e31..c9e081a 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1271,8 +1271,8 @@ function! NERDComment(mode, type) range let l:commentAllLines = 0 for i in range(firstLine, lastLine) let theLine = getline(i) - " if have one line no comment, then comment all lines - if !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + " if have one line no comment(not include blank/whitespace-only lines), then comment all lines + if theLine =~ '[^ \t]\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) let l:commentAllLines = 1 break else From 17b68e47d781b9fcbf1c77495e535eab366f20ca Mon Sep 17 00:00:00 2001 From: Jingchang Shi Date: Wed, 17 Apr 2019 17:11:07 +0800 Subject: [PATCH 21/21] Add an option: NERDDisableTabsInBlockComm (#374) * Add an option: NERDDisableTabsInBlockComm. 1 disables adding tabs before the comment symbols in the block style. * Add doc for the new option. --- doc/NERD_commenter.txt | 24 ++++++++++++++++++++++++ plugin/NERD_commenter.vim | 13 +++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index daf8b96..5a14a4d 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -811,6 +811,30 @@ Default 0. When this option is set to 1, NERDCommenterToggle will check all selected line, if there have oneline not be commented, then comment all lines. +------------------------------------------------------------------------------ + *'NERDDisableTabsInBlockComm'* +Values: 0 or 1. +Default 0. + +When this option is set to 1, NERDDisableTabsInBlockComm will not add +whitespaces align the start location of the ending comment symbol with the +end location of the starting comment symbol. For example, in Fortran, the new +style will be as the following: > + close (inpt,iostat=ierr,iomsg=error_message) + call io_error(pname,input_fname,2,__LINE__,__FILE__,ierr,error_message) +< +to > + !===BEGIN===! + ! close (inpt,iostat=ierr,iomsg=error_message) + ! call io_error(pname,input_fname,2,__LINE__,__FILE__,ierr,error_message) + !===END===! +< +for the block comment style if customized comment symbols are set up in vimrc +file by the following line > + let g:NERDCustomDelimiters = { + \ 'fortran':{'left':'!','leftAlt':'!===BEGIN===!','rightAlt':'!===END===!'} + \ } +< ------------------------------------------------------------------------------ 3.3 Default delimiter customisation *NERDComDefaultDelims* diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index c9e081a..5005b22 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -66,6 +66,7 @@ call s:InitVariable("g:NERDSpaceDelims", 0) call s:InitVariable("g:NERDDefaultAlign", "none") call s:InitVariable("g:NERDTrimTrailingWhitespace", 0) call s:InitVariable("g:NERDToggleCheckAllLines", 0) +call s:InitVariable("g:NERDDisableTabsInBlockComm", 0) let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" @@ -997,7 +998,11 @@ function s:CommentLinesSexy(topline, bottomline) " the lines down when we added the left delimiter call cursor(a:bottomline+1, 1) execute 'normal! o' - let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right + if g:NERDDisableTabsInBlockComm + let theLine = repeat(' ', leftAlignIndx) . right + else + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right + endif " Make sure tabs are respected if !&expandtab @@ -1023,7 +1028,11 @@ function s:CommentLinesSexy(topline, bottomline) endif " add the sexyComMarker - let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) + if g:NERDDisableTabsInBlockComm + let theLine = repeat(' ', leftAlignIndx) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) + else + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) + endif if lineHasTabs let theLine = s:ConvertLeadingSpacesToTabs(theLine)