remove useless "align right" comments

This commit is contained in:
Martin Grenfell
2008-09-23 21:39:06 +12:00
parent 6bf14ce062
commit b8c5a4443c
2 changed files with 21 additions and 27 deletions

View File

@@ -116,11 +116,9 @@ Switches to the alternative set of delimiters.
[count]<leader>cl [count]<leader>cl
[count]<leader>cr
[count]<leader>cb |NERDComAlignedComment| [count]<leader>cb |NERDComAlignedComment|
Same as |NERDComComment| except that the delimiters are aligned down the Same as |NERDComComment| except that the delimiters are aligned down the
left side (<leader>cl), the right side (<leader>cr) or both sides left side (<leader>cl) or both sides (<leader>cb).
(<leader>cb).
[count]<leader>cu |NERDComUncommentLine| [count]<leader>cu |NERDComUncommentLine|
@@ -313,14 +311,13 @@ See also |NERDComDefaultDelims|
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
2.2.13 Comment aligned maps *NERDComAlignedComment* 2.2.13 Comment aligned maps *NERDComAlignedComment*
Default mappings: [count]<leader>cl [count]<leader>cr [count]<leader>cb Default mappings: [count]<leader>cl [count]<leader>cb
Mapped to: <plug>NERDCommenterAlignLeft Mapped to: <plug>NERDCommenterAlignLeft
<plug>NERDCommenterAlignRight
<plug>NERDCommenterAlignBoth <plug>NERDCommenterAlignBoth
Applicable modes: normal visual-line. Applicable modes: normal visual-line.
Same as <leader>cc except that the comment delimiters are aligned on the left Same as <leader>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 the line(s) are already commented.
If a [count] is given in normal mode, the mapping works as though that many 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. line.
- type: is used to specify what type of commenting operation is to be - type: is used to specify what type of commenting operation is to be
performed, and it can be one of the following: "sexy", "invert", 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" "nested", "toEOL", "prepend", "append", "insert", "uncomment", "yank"
For example, if you typed > For example, if you typed >

View File

@@ -1147,10 +1147,9 @@ endfunction
" Args: " Args:
" -forceNested: a flag indicating whether the called is requesting the comment " -forceNested: a flag indicating whether the called is requesting the comment
" to be nested if need be " to be nested if need be
" -alignRight/alignLeft: 0/1 if the comments delimiters should/shouldnt be " -align: should be "left" or "both" or "none"
" aligned left/right
" -firstLine/lastLine: the top and bottom lines to comment " -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 " 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 " block of of lines and the right most char so that we can do alignment of
" the delimiters if the user has specified " 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 " check if we can comment this line
if !isCommented || g:NERDUsePlaceHolders || s:Multipart() 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) let theLine = s:AddLeftDelimAligned(s:GetLeft(0,1,0), theLine, leftAlignIndx)
else else
let theLine = s:AddLeftDelim(s:GetLeft(0,1,0), theLine) let theLine = s:AddLeftDelim(s:GetLeft(0,1,0), theLine)
endif endif
if a:alignRight if a:align == "both"
let theLine = s:AddRightDelimAligned(s:GetRight(0,1,0), theLine, rightAlignIndx) let theLine = s:AddRightDelimAligned(s:GetRight(0,1,0), theLine, rightAlignIndx)
else else
let theLine = s:AddRightDelim(s:GetRight(0,1,0), theLine) 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 topOfRange = a:topLine+1
let bottomOfRange = a:bottomLine-1 let bottomOfRange = a:bottomLine-1
if topOfRange <= bottomOfRange if topOfRange <= bottomOfRange
call s:CommentLines(a:forceNested, 0, 0, topOfRange, bottomOfRange) call s:CommentLines(a:forceNested, "none", topOfRange, bottomOfRange)
endif endif
"comment the bottom line "comment the bottom line
@@ -1494,14 +1493,14 @@ function s:InvertComment(firstLine, lastLine)
endwhile endwhile
endfunction 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 " This function is a Wrapper for the main commenting functions
" "
" Args: " Args:
" -isVisual: a flag indicating whether the comment is requested in visual " -isVisual: a flag indicating whether the comment is requested in visual
" mode or not " mode or not
" -type: the type of commenting requested. Can be 'sexy', 'invert', " -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' " 'nested', 'toEOL', 'prepend', 'append', 'insert', 'uncomment', 'yank'
function! NERDComment(isVisual, type) range function! NERDComment(isVisual, type) range
" we want case sensitivity when commenting " 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())) elseif a:isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims()))
call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested) call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested)
else else
call s:CommentLines(forceNested, 0, 0, firstLine, lastLine) call s:CommentLines(forceNested, "none", firstLine, lastLine)
endif endif
elseif a:type == 'alignLeft' || a:type == 'alignRight' || a:type == 'alignBoth' elseif a:type == 'alignLeft' || a:type == 'alignBoth'
let alignLeft = (a:type == 'alignLeft' || a:type == 'alignBoth') let align = "none"
let alignRight = (a:type == 'alignRight' || a:type == 'alignBoth') if a:type == "alignLeft"
call s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) let align = "left"
elseif a:type == "alignBoth"
let align = "both"
endif
call s:CommentLines(forceNested, align, firstLine, lastLine)
elseif a:type == 'invert' elseif a:type == 'invert'
call s:InvertComment(firstLine, lastLine) call s:InvertComment(firstLine, lastLine)
@@ -1543,7 +1546,7 @@ function! NERDComment(isVisual, type) range
try try
call s:CommentLinesSexy(firstLine, lastLine) call s:CommentLinesSexy(firstLine, lastLine)
catch /NERDCommenter.Delimiters/ catch /NERDCommenter.Delimiters/
call s:CommentLines(forceNested, 0, 0, firstLine, lastLine) call s:CommentLines(forceNested, "none", firstLine, lastLine)
catch /NERDCommenter.Nesting/ catch /NERDCommenter.Nesting/
call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0) call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0)
endtry endtry
@@ -3260,10 +3263,6 @@ vmap <silent> <plug>NERDCommenterYank <ESC>:call NERDComment(1, "yank")<CR>
nnoremap <silent> <plug>NERDCommenterAlignLeft :call NERDComment(0, "alignLeft")<cr> nnoremap <silent> <plug>NERDCommenterAlignLeft :call NERDComment(0, "alignLeft")<cr>
vnoremap <silent> <plug>NERDCommenterAlignLeft <ESC>:call NERDComment(1, "alignLeft")<cr> vnoremap <silent> <plug>NERDCommenterAlignLeft <ESC>:call NERDComment(1, "alignLeft")<cr>
" right aligned comments
nnoremap <silent> <plug>NERDCommenterAlignRight :call NERDComment(0, "alignRight")<cr>
vnoremap <silent> <plug>NERDCommenterAlignRight <ESC>:call NERDComment(1, "alignRight")<cr>
" left and right aligned comments " left and right aligned comments
nnoremap <silent> <plug>NERDCommenterAlignBoth :call NERDComment(0, "alignBoth")<cr> nnoremap <silent> <plug>NERDCommenterAlignBoth :call NERDComment(0, "alignBoth")<cr>
vnoremap <silent> <plug>NERDCommenterAlignBoth <ESC>:call NERDComment(1, "alignBoth")<cr> vnoremap <silent> <plug>NERDCommenterAlignBoth <ESC>:call NERDComment(1, "alignBoth")<cr>
@@ -3307,7 +3306,6 @@ if g:NERDCreateDefaultMappings
call s:CreateMaps('<plug>NERDCommenterInvert', '<leader>ci') call s:CreateMaps('<plug>NERDCommenterInvert', '<leader>ci')
call s:CreateMaps('<plug>NERDCommenterYank', '<leader>cy') call s:CreateMaps('<plug>NERDCommenterYank', '<leader>cy')
call s:CreateMaps('<plug>NERDCommenterAlignLeft', '<leader>cl') call s:CreateMaps('<plug>NERDCommenterAlignLeft', '<leader>cl')
call s:CreateMaps('<plug>NERDCommenterAlignRight', '<leader>cr')
call s:CreateMaps('<plug>NERDCommenterAlignBoth', '<leader>cb') call s:CreateMaps('<plug>NERDCommenterAlignBoth', '<leader>cb')
call s:CreateMaps('<plug>NERDCommenterNest', '<leader>cn') call s:CreateMaps('<plug>NERDCommenterNest', '<leader>cn')
call s:CreateMaps('<plug>NERDCommenterUncomment', '<leader>cu') call s:CreateMaps('<plug>NERDCommenterUncomment', '<leader>cu')
@@ -3352,7 +3350,6 @@ if g:NERDMenuMode != 0
exec 'nmenu <silent> '. menuRoot .'.Prepend <plug>NERDCommenterPrepend' exec 'nmenu <silent> '. menuRoot .'.Prepend <plug>NERDCommenterPrepend'
exec 'menu <silent> '. menuRoot .'.-Sep- :' exec 'menu <silent> '. menuRoot .'.-Sep- :'
call s:CreateMenuItems('<plug>NERDCommenterAlignLeft', 'Left\ aligned', menuRoot) call s:CreateMenuItems('<plug>NERDCommenterAlignLeft', 'Left\ aligned', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterAlignRight', 'Right\ aligned', menuRoot)
call s:CreateMenuItems('<plug>NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot) call s:CreateMenuItems('<plug>NERDCommenterAlignBoth', 'Left\ and\ right\ aligned', menuRoot)
exec 'menu <silent> '. menuRoot .'.-Sep2- :' exec 'menu <silent> '. menuRoot .'.-Sep2- :'
call s:CreateMenuItems('<plug>NERDCommenterUncomment', 'Uncomment', menuRoot) call s:CreateMenuItems('<plug>NERDCommenterUncomment', 'Uncomment', menuRoot)