@@ -65,6 +65,7 @@ call s:InitVariable("g:NERDRPlace", "<]")
6565call s: InitVariable (" g:NERDSpaceDelims" , 0 )
6666call s: InitVariable (" g:NERDDefaultAlign" , " none" )
6767call s: InitVariable (" g:NERDTrimTrailingWhitespace" , 0 )
68+ call s: InitVariable (" g:NERDToggleCheckAllLines" , 0 )
6869
6970let s: NERDFileNameEscape= " []#*$%'\" ?`!&();<>\\ "
7071
@@ -1258,12 +1259,29 @@ function! NERDComment(mode, type) range
12581259 endtry
12591260
12601261 elseif a: type == ? ' Toggle'
1261- let theLine = getline (firstLine)
1262-
1263- if s: IsInSexyComment (firstLine) || s: IsCommentedFromStartOfLine (s: Left (), theLine) || s: IsCommentedFromStartOfLine (s: Left ({' alt' : 1 }), theLine)
1264- call s: UncommentLines (firstLine, lastLine)
1262+ if g: NERDToggleCheckAllLines == # 0
1263+ let theLine = getline (firstLine)
1264+ if s: IsInSexyComment (firstLine) || s: IsCommentedFromStartOfLine (s: Left (), theLine) || s: IsCommentedFromStartOfLine (s: Left ({' alt' : 1 }), theLine)
1265+ call s: UncommentLines (firstLine, lastLine)
1266+ else
1267+ call s: CommentLinesToggle (forceNested, firstLine, lastLine)
1268+ endif
12651269 else
1270+ let l: commentAllLines = 0
1271+ for i in range (firstLine, lastLine)
1272+ let theLine = getline (i )
1273+ " if have one line no comment, then comment all lines
1274+ if ! s: IsInSexyComment (firstLine) && ! s: IsCommentedFromStartOfLine (s: Left (), theLine) && ! s: IsCommentedFromStartOfLine (s: Left ({' alt' : 1 }), theLine)
1275+ let l: commentAllLines = 1
1276+ break
1277+ else
1278+ endif
1279+ endfor
1280+ if l: commentAllLines == # 1
12661281 call s: CommentLinesToggle (forceNested, firstLine, lastLine)
1282+ else
1283+ call s: UncommentLines (firstLine, lastLine)
1284+ endif
12671285 endif
12681286
12691287 elseif a: type == ? ' Minimal'
0 commit comments