diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index eff63d1..3318011 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -3,7 +3,7 @@ " Description: vim global plugin that provides easy code commenting " Maintainer: Martin Grenfell " Version: 2.3.0 -" Last Change: Mon Dec 12 11:00 AM 2011 EST +" Last Change: Mon Dec 12 10:00 PM 2011 EST " License: This program is free software. It comes without any warranty, " to the extent permitted by applicable law. You can redistribute " it and/or modify it under the terms of the Do What The Fuck You @@ -1023,7 +1023,7 @@ endfunction " -mode: a character indicating the mode in which the comment is requested: " 'n' for Normal mode, 'v' for Visual mode " -type: the type of commenting requested. Can be 'Sexy', 'Invert', -" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Norm', +" 'Minimal', 'Toggle', 'AlignLeft', 'AlignBoth', 'Comment', " 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' function! s:NERDComment(mode, type) range " we want case sensitivity when commenting @@ -1048,7 +1048,7 @@ function! s:NERDComment(mode, type) range let forceNested = (a:type == 'Nested' || g:NERDDefaultNesting) - if a:type == 'Norm' || a:type == 'Nested' + if a:type == 'Comment' || a:type == 'Nested' if a:mode == "v" && visualmode() == "\" call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested) elseif a:mode == "v" && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims())) @@ -1118,7 +1118,7 @@ function! s:NERDComment(mode, type) range else normal! yy endif - execute firstLine .','. lastLine .'call s:NERDComment('. a:mode .', "Norm")' + execute firstLine .','. lastLine .'call s:NERDComment("'. a:mode .'", "Comment")' endif let &ignorecase = oldIgnoreCase @@ -2687,62 +2687,7 @@ function s:UntabbedCol(line, col) let lineTabsToSpaces = substitute(lineTruncated, '\t', s:TabSpace(), 'g') return strlen(lineTabsToSpaces) endfunction -" Section: Comment mapping setup {{{1 -" =========================================================================== - -" switch to/from alternative delimiters -nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1) - -" comment out lines -nnoremap NERDCommenterComment :call NERDComment("n", "Norm") -vnoremap NERDCommenterComment :call NERDComment("v", "Norm") - -" toggle comments -nnoremap NERDCommenterToggle :call NERDComment("n", "Toggle") -vnoremap NERDCommenterToggle :call NERDComment("v", "Toggle") - -" minimal comments -nnoremap NERDCommenterMinimal :call NERDComment("n", "Minimal") -vnoremap NERDCommenterMinimal :call NERDComment("v", "Minimal") - -" sexy comments -nnoremap NERDCommenterSexy :call NERDComment("n", "Sexy") -vnoremap NERDCommenterSexy :call NERDComment("v", "Sexy") - -" invert comments -nnoremap NERDCommenterInvert :call NERDComment("n", "Invert") -vnoremap NERDCommenterInvert :call NERDComment("v", "Invert") - -" yank then comment -nmap NERDCommenterYank :call NERDComment("n", "Yank") -vmap NERDCommenterYank :call NERDComment("v", "Yank") - -" left aligned comments -nnoremap NERDCommenterAlignLeft :call NERDComment("n", "AlignLeft") -vnoremap NERDCommenterAlignLeft :call NERDComment("v", "AlignLeft") - -" left and right aligned comments -nnoremap NERDCommenterAlignBoth :call NERDComment("n", "AlignBoth") -vnoremap NERDCommenterAlignBoth :call NERDComment("v", "AlignBoth") - -" nested comments -nnoremap NERDCommenterNest :call NERDComment("n", "Nested") -vnoremap NERDCommenterNest :call NERDComment("v", "Nested") - -" uncomment -nnoremap NERDCommenterUncomment :call NERDComment("n", "Uncomment") -vnoremap NERDCommenterUncomment :call NERDComment("v", "Uncomment") - -" comment till the end of the line -nnoremap NERDCommenterToEOL :call NERDComment("n", "ToEOL") - -" append comments -nmap NERDCommenterAppend :call NERDComment("n", "Append") - -" insert comments -inoremap NERDCommenterInsert :call NERDComment("n", "Insert") - -" Section: Menu item setup {{{1 +" Section: Comment mapping and menu item setup {{{1 " =========================================================================== " Create menu items for the specified modes. If a:combo is not empty, then @@ -2757,6 +2702,7 @@ function! s:CreateMaps(modes, target, desc, combo) endif let command .= ' ' . a:target for mode in (a:modes == '') ? [''] : split(a:modes, '\zs') + exec mode . 'noremap ' . a:target . ' :call NERDComment("' . mode . '", "' . substitute(a:target, 'NERDCommenter', '', '') . '")' if g:NERDCreateDefaultMappings \ && strlen(a:combo) && !hasmapto(a:target, mode) exec mode . 'map ' . a:combo . ' ' . a:target @@ -2770,7 +2716,7 @@ endfunction call s:CreateMaps('nx', 'NERDCommenterComment', 'Comment', 'cc') call s:CreateMaps('nx', 'NERDCommenterToggle', 'Toggle', 'c') call s:CreateMaps('nx', 'NERDCommenterMinimal', 'Minimal', 'cm') -call s:CreateMaps('nx', 'NERDCommenterNest', 'Nested', 'cn') +call s:CreateMaps('nx', 'NERDCommenterNested', 'Nested', 'cn') call s:CreateMaps('n', 'NERDCommenterToEOL', 'To EOL', 'c$') call s:CreateMaps('nx', 'NERDCommenterInvert', 'Invert', 'ci') call s:CreateMaps('nx', 'NERDCommenterSexy', 'Sexy', 'cs') @@ -2785,4 +2731,7 @@ call s:CreateMaps('n', 'NERDCommenterAltDelims', 'Switch Delimiters', 'ca') call s:CreateMaps('i', 'NERDCommenterInsert', 'Insert Comment Here', '') call s:CreateMaps('', ':', '-Sep3-', '') call s:CreateMaps('', ':help NERDCommenterContents', 'Help', '') + +" switch to/from alternative delimiters (does not use wrapper function) +nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1) " vim: set foldmethod=marker :