From 45689b2356ae1550b0e8331a02778bafa5d0acfa Mon Sep 17 00:00:00 2001 From: kaidiren Date: Wed, 31 Aug 2016 14:32:26 +0800 Subject: [PATCH] can enable TrimTrailingWhitespace when comment --- plugin/NERD_commenter.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 37282c9..8b8c297 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -746,6 +746,10 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif + if g:NERDTrimTrailingWhitespace == 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + call setline(currentLine, theLine) endif @@ -816,6 +820,10 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif + if g:NERDTrimTrailingWhitespace == 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + " we are done with this line call setline(currentLine, theLine) let currentLine = currentLine + 1 @@ -876,6 +884,11 @@ function s:CommentLinesMinimal(firstLine, lastLine) if lineHasLeadingTabs let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif + + if g:NERDTrimTrailingWhitespace == 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + call setline(a:lastLine, theLine) endfunction @@ -995,6 +1008,9 @@ function s:CommentLinesSexy(topline, bottomline) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif + if g:NERDTrimTrailingWhitespace == 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif " set the line and move onto the next one call setline(currentLine, theLine) @@ -1049,6 +1065,10 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif + if g:NERDTrimTrailingWhitespace == 1 + let theLine = s:TrimTrailingWhitespace(theLine) + endif + " we are done with this line call setline(currentLine, theLine) let currentLine = currentLine + 1