diff --git a/README.md b/README.md index 59962867..08bd4a95 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 5d32d38f..fcf1c59e 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -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="[]#*$%'\" ?`!&();<>\\" @@ -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': '*%' }, @@ -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': '//' }, @@ -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) @@ -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') +call s:CreateMaps('nx', 'SexyToggle', 'SexyToggle', 'c') +call s:CreateMaps('nx', 'NormalToggle', 'NormalToggle', 'c') call s:CreateMaps('nx', 'Minimal', 'Minimal', 'cm') call s:CreateMaps('nx', 'Nested', 'Nested', 'cn') call s:CreateMaps('n', 'ToEOL', 'To EOL', 'c$')