From 76c8e7223cf3a036d05671faa6a47f74e84b5c5d Mon Sep 17 00:00:00 2001 From: J-S-Kim Date: Tue, 6 Jun 2017 16:15:01 +0900 Subject: [PATCH] fix sexy comment //-style in C/C++ --- plugin/NERD_commenter.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index df14ecef..3e038b29 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1003,6 +1003,13 @@ function s:CommentLinesSexy(topline, bottomline) while currentLine <= a:bottomline + !g:NERDCompactSexyComs " get the line and convert the tabs to spaces let theLine = getline(currentLine) + + if s:IsCommentedFromStartOfLine("/", theLine) && s:HasCStyleComments() + let comMarker = sexyComMarker . s:spaceStr + else + let comMarker = sexyComMarkerSpaced + endif + let lineHasTabs = s:HasLeadingTabs(theLine) if lineHasTabs let theLine = s:ConvertLeadingTabsToSpaces(theLine) @@ -1013,7 +1020,7 @@ function s:CommentLinesSexy(topline, bottomline) endif " add the sexyComMarker - let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . sexyComMarkerSpaced . strpart(theLine, leftAlignIndx) + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . comMarker . strpart(theLine, leftAlignIndx) if lineHasTabs let theLine = s:ConvertLeadingSpacesToTabs(theLine)