From b8c5a4443c33172cf50df4898670ed1eb207124b Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 23 Sep 2008 21:39:06 +1200 Subject: [PATCH] remove useless "align right" comments --- doc/NERD_commenter.txt | 11 ++++------- plugin/NERD_commenter.vim | 37 +++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index cc822bc..9852a31 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -116,11 +116,9 @@ Switches to the alternative set of delimiters. [count]cl -[count]cr [count]cb |NERDComAlignedComment| Same as |NERDComComment| except that the delimiters are aligned down the -left side (cl), the right side (cr) or both sides -(cb). +left side (cl) or both sides (cb). [count]cu |NERDComUncommentLine| @@ -313,14 +311,13 @@ See also |NERDComDefaultDelims| ------------------------------------------------------------------------------ 2.2.13 Comment aligned maps *NERDComAlignedComment* -Default mappings: [count]cl [count]cr [count]cb +Default mappings: [count]cl [count]cb Mapped to: NERDCommenterAlignLeft - NERDCommenterAlignRight NERDCommenterAlignBoth Applicable modes: normal visual-line. Same as cc except that the comment delimiters are aligned on the left -side, right side or both sides respectively. These comments are always nested +side or both sides respectively. These comments are always nested if the line(s) are already commented. If a [count] is given in normal mode, the mapping works as though that many @@ -413,7 +410,7 @@ The arguments to this function are simple: line. - type: is used to specify what type of commenting operation is to be performed, and it can be one of the following: "sexy", "invert", - "minimal", "toggle", "alignLeft", "alignRight", "alignBoth", "norm", + "minimal", "toggle", "alignLeft", "alignBoth", "norm", "nested", "toEOL", "prepend", "append", "insert", "uncomment", "yank" For example, if you typed > diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 0857bf2..710cece 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1147,10 +1147,9 @@ endfunction " Args: " -forceNested: a flag indicating whether the called is requesting the comment " to be nested if need be -" -alignRight/alignLeft: 0/1 if the comments delimiters should/shouldnt be -" aligned left/right +" -align: should be "left" or "both" or "none" " -firstLine/lastLine: the top and bottom lines to comment -function s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) +function s:CommentLines(forceNested, align, firstLine, lastLine) " we need to get the left and right indexes of the leftmost char in the " block of of lines and the right most char so that we can do alignment of " the delimiters if the user has specified @@ -1182,12 +1181,12 @@ function s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) " check if we can comment this line if !isCommented || g:NERDUsePlaceHolders || s:Multipart() - if a:alignLeft + if a:align == "left" || a:align == "both" let theLine = s:AddLeftDelimAligned(s:GetLeft(0,1,0), theLine, leftAlignIndx) else let theLine = s:AddLeftDelim(s:GetLeft(0,1,0), theLine) endif - if a:alignRight + if a:align == "both" let theLine = s:AddRightDelimAligned(s:GetRight(0,1,0), theLine, rightAlignIndx) else let theLine = s:AddRightDelim(s:GetRight(0,1,0), theLine) @@ -1436,7 +1435,7 @@ function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) let topOfRange = a:topLine+1 let bottomOfRange = a:bottomLine-1 if topOfRange <= bottomOfRange - call s:CommentLines(a:forceNested, 0, 0, topOfRange, bottomOfRange) + call s:CommentLines(a:forceNested, "none", topOfRange, bottomOfRange) endif "comment the bottom line @@ -1494,14 +1493,14 @@ function s:InvertComment(firstLine, lastLine) endwhile endfunction -" Function: NERDComment(isVisual, alignLeft, alignRight, type) function {{{2 +" Function: NERDComment(isVisual, type) function {{{2 " This function is a Wrapper for the main commenting functions " " Args: " -isVisual: a flag indicating whether the comment is requested in visual " mode or not " -type: the type of commenting requested. Can be 'sexy', 'invert', -" 'minimal', 'toggle', 'alignLeft', 'alignRight', 'alignBoth', 'norm', +" 'minimal', 'toggle', 'alignLeft', 'alignBoth', 'norm', " 'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment', 'yank' function! NERDComment(isVisual, type) range " we want case sensitivity when commenting @@ -1528,13 +1527,17 @@ function! NERDComment(isVisual, type) range elseif a:isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims())) call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested) else - call s:CommentLines(forceNested, 0, 0, firstLine, lastLine) + call s:CommentLines(forceNested, "none", firstLine, lastLine) endif - elseif a:type == 'alignLeft' || a:type == 'alignRight' || a:type == 'alignBoth' - let alignLeft = (a:type == 'alignLeft' || a:type == 'alignBoth') - let alignRight = (a:type == 'alignRight' || a:type == 'alignBoth') - call s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) + elseif a:type == 'alignLeft' || a:type == 'alignBoth' + let align = "none" + if a:type == "alignLeft" + let align = "left" + elseif a:type == "alignBoth" + let align = "both" + endif + call s:CommentLines(forceNested, align, firstLine, lastLine) elseif a:type == 'invert' call s:InvertComment(firstLine, lastLine) @@ -1543,7 +1546,7 @@ function! NERDComment(isVisual, type) range try call s:CommentLinesSexy(firstLine, lastLine) catch /NERDCommenter.Delimiters/ - call s:CommentLines(forceNested, 0, 0, firstLine, lastLine) + call s:CommentLines(forceNested, "none", firstLine, lastLine) catch /NERDCommenter.Nesting/ call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0) endtry @@ -3260,10 +3263,6 @@ vmap NERDCommenterYank :call NERDComment(1, "yank") nnoremap NERDCommenterAlignLeft :call NERDComment(0, "alignLeft") vnoremap NERDCommenterAlignLeft :call NERDComment(1, "alignLeft") -" right aligned comments -nnoremap NERDCommenterAlignRight :call NERDComment(0, "alignRight") -vnoremap NERDCommenterAlignRight :call NERDComment(1, "alignRight") - " left and right aligned comments nnoremap NERDCommenterAlignBoth :call NERDComment(0, "alignBoth") vnoremap NERDCommenterAlignBoth :call NERDComment(1, "alignBoth") @@ -3307,7 +3306,6 @@ if g:NERDCreateDefaultMappings call s:CreateMaps('NERDCommenterInvert', 'ci') call s:CreateMaps('NERDCommenterYank', 'cy') call s:CreateMaps('NERDCommenterAlignLeft', 'cl') - call s:CreateMaps('NERDCommenterAlignRight', 'cr') call s:CreateMaps('NERDCommenterAlignBoth', 'cb') call s:CreateMaps('NERDCommenterNest', 'cn') call s:CreateMaps('NERDCommenterUncomment', 'cu') @@ -3352,7 +3350,6 @@ if g:NERDMenuMode != 0 exec 'nmenu '. menuRoot .'.Prepend NERDCommenterPrepend' exec 'menu '. menuRoot .'.-Sep- :' call s:CreateMenuItems('NERDCommenterAlignLeft', 'Left\ aligned', menuRoot) - call s:CreateMenuItems('NERDCommenterAlignRight', 'Right\ aligned', menuRoot) call s:CreateMenuItems('NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot) exec 'menu '. menuRoot .'.-Sep2- :' call s:CreateMenuItems('NERDCommenterUncomment', 'Uncomment', menuRoot)