mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-09 10:13:48 -05:00
Allow commenting empty lines given configuration (#250)
* Allow commenting empty lines given configuration
If g:NERDCommentEmptyLines=1 then it will comment empty line, which is
useful when commenting blocks.
When uncommenting it will delete any trailing whitespace.
* Add documentation for NERDCommentEmptyLines
This commit is contained in:
committed by
Caleb Maclennan
parent
06c3184b2e
commit
e1aeec12be
@@ -88,6 +88,9 @@ let g:NERDAltDelims_java = 1
|
|||||||
|
|
||||||
" Add your own custom formats or override the defaults
|
" Add your own custom formats or override the defaults
|
||||||
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
|
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
|
||||||
|
|
||||||
|
" Allow commenting and inverting empty lines (useful when commenting a region)
|
||||||
|
g:NERDCommentEmptyLines = 1
|
||||||
```
|
```
|
||||||
|
|
||||||
### Default mappings
|
### Default mappings
|
||||||
|
|||||||
@@ -437,6 +437,9 @@ change the filetype back: >
|
|||||||
|'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed
|
|'NERDBlockComIgnoreEmpty'| Forces right delimiters to be placed
|
||||||
when doing visual-block comments.
|
when doing visual-block comments.
|
||||||
|
|
||||||
|
|'NERDCommentEmptyLines'| Specifies if empty lines should be
|
||||||
|
commented (useful with regions).
|
||||||
|
|
||||||
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|
||||||
|
|
||||||
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|
|'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'*
|
*'NERDCommentWholeLinesInVMode'*
|
||||||
Values: 0, 1 or 2.
|
Values: 0, 1 or 2.
|
||||||
|
|||||||
@@ -1810,8 +1810,9 @@ function s:CanToggleCommentLine(forceNested, lineNum)
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" make sure we don't comment lines that are just spaces or tabs or empty.
|
" make sure we don't comment lines that are just spaces or tabs or empty,
|
||||||
if theLine =~ "^[ \t]*$"
|
" unless configured otherwise
|
||||||
|
if g:NERDCommentEmptyLines == 0 && theLine =~ "^[ \t]*$"
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user