diff --git a/README.md b/README.md index e566b8e..a6944ef 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,9 @@ let g:NERDAltDelims_java = 1 " Add your own custom formats or override the defaults let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } + +" Allow commenting and inverting empty lines (useful when commenting a region) +g:NERDCommentEmptyLines = 1 ``` ### Default mappings diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 9da1ec8..93d2a6f 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -437,6 +437,9 @@ change the filetype back: > |'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed when doing visual-block comments. +|'NERDCommentEmptyLines'| Specifies if empty lines should be + commented (useful with regions). + |'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments. |'NERDCreateDefaultMappings'| Turn the default mappings on/off. @@ -559,6 +562,15 @@ Otherwise, the code block would become: > } /*} */ < +------------------------------------------------------------------------------ + *'NERDCommentEmptyLines'* +Values: 0 or 1. +Default: 0. + +This option affects commenting of empty lines. If this option is turned on, +then empty lines will be commented as well. Useful when commenting regions of +code. + ------------------------------------------------------------------------------ *'NERDCommentWholeLinesInVMode'* Values: 0, 1 or 2. diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 985a27f..d05ae46 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1810,8 +1810,9 @@ function s:CanToggleCommentLine(forceNested, lineNum) return 0 endif - " make sure we don't comment lines that are just spaces or tabs or empty. - if theLine =~ "^[ \t]*$" + " make sure we don't comment lines that are just spaces or tabs or empty, + " unless configured otherwise + if g:NERDCommentEmptyLines == 0 && theLine =~ "^[ \t]*$" return 0 endif