From 5d42b2ec5cd8101d594de4414d4ae09fb1c61fa0 Mon Sep 17 00:00:00 2001 From: Tim-Smart Date: Fri, 11 Sep 2009 19:43:16 +1200 Subject: [PATCH] s:CommentLinesSexy - Fixed issue #2 . Tabs now respected in sexy comments. --- plugin/NERD_commenter.vim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 96b3251..4ee0f85 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1147,13 +1147,24 @@ function s:CommentLinesSexy(topline, bottomline) " add the left delimiter one line above the lines that are to be commented call cursor(a:topline, 1) execute 'normal! O' - call setline(a:topline, repeat(' ', leftAlignIndx) . left ) + + " Make sure tabs are respected + if !&expandtab + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:topline, theLine) " add the right delimiter after bottom line (we have to add 1 cos we moved " the lines down when we added the left delim call cursor(a:bottomline+1, 1) execute 'normal! o' - call setline(a:bottomline+2, repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right ) + let theLine = repeat(' ', leftAlignIndx) . repeat(' ', strlen(left)-strlen(sexyComMarker)) . right + + " Make sure tabs are respected + if !&expandtab + let theLine = s:ConvertLeadingSpacesToTabs(theLine) + endif + call setline(a:bottomline+2, theLine) endif