Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1

" Enable Sexy Comments while Toggling. Default behaviour is normal comments.
let g:NERDToggleSexyComments = 1

" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1
```
Expand Down
18 changes: 13 additions & 5 deletions plugin/NERD_commenter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ call s:InitVariable('g:NERDDefaultAlign', 'none')
call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
call s:InitVariable('g:NERDToggleCheckAllLines', 0)
call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
call s:InitVariable("g:NERDToggleSexyComments", 0)

let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"

Expand All @@ -73,7 +74,7 @@ let s:delimiterMap = {
\ 'applescript': { 'left': '--', 'leftAlt': '(*', 'rightAlt': '*)' },
\ 'armasm': { 'left': ';' },
\ 'asciidoc': { 'left': '//' },
\ 'asm': { 'left': ';', 'leftAlt': '#' },
\ 'asm': { 'left': '#', 'leftAlt': ';' },
\ 'asm68k': { 'left': ';' },
\ 'asn': { 'left': '--' },
\ 'asp': { 'left': '%', 'leftAlt': '%*', 'rightAlt': '*%' },
Expand All @@ -91,9 +92,6 @@ let s:delimiterMap = {
\ 'bc': { 'left': '#' },
\ 'bib': { 'left': '//' },
\ 'bindzone': { 'left': ';' },
\ 'blade': { 'left': '{{--', 'right': '--}}' },
\ 'bst': { 'left': '%' },
\ 'btm': { 'left': '::' },
\ 'c': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'cabal': { 'left': '--' },
\ 'calibre': { 'left': '//' },
Expand Down Expand Up @@ -1298,6 +1296,15 @@ function! NERDComment(mode, type) range
endif
endif

if s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
call s:UncommentLines(firstLine, lastLine)
elseif g:NERDToggleSexyComments == 1
call s:SwitchToAlternativeDelimiters(0)
call s:CommentLinesToggle(forceNested, firstLine, lastLine)
call s:SwitchToAlternativeDelimiters(0)
else
call s:CommentLinesToggle(forceNested, firstLine, lastLine)
endif
elseif a:type ==? 'Minimal'
try
call s:CommentLinesMinimal(firstLine, lastLine)
Expand Down Expand Up @@ -3169,7 +3176,8 @@ function! s:CreateMaps(modes, target, desc, combo)
endfor
endfunction
call s:CreateMaps('nx', 'Comment', 'Comment', 'cc')
call s:CreateMaps('nx', 'Toggle', 'Toggle', 'c<space>')
call s:CreateMaps('nx', 'SexyToggle', 'SexyToggle', 'c<space>')
call s:CreateMaps('nx', 'NormalToggle', 'NormalToggle', 'c<space>')
call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm')
call s:CreateMaps('nx', 'Nested', 'Nested', 'cn')
call s:CreateMaps('n', 'ToEOL', 'To EOL', 'c$')
Expand Down