Fix lint warning: prefer single quoted strings

This commit is contained in:
Caleb Maclennan 2019-12-30 10:53:41 +03:00
parent 6d51d1b334
commit ac3db1e70a
No known key found for this signature in database
GPG Key ID: 63CC496475267693

View File

@ -14,7 +14,7 @@
" ============================================================================ " ============================================================================
" Section: script init stuff {{{1 " Section: script init stuff {{{1
if exists("loaded_nerd_comments") if exists('loaded_nerd_comments')
finish finish
endif endif
if v:version < 700 if v:version < 700
@ -49,24 +49,24 @@ let s:spaceStr = ' '
let s:lenSpaceStr = strlen(s:spaceStr) let s:lenSpaceStr = strlen(s:spaceStr)
" Section: variable initialization {{{2 " Section: variable initialization {{{2
call s:InitVariable("g:NERDAllowAnyVisualDelims", 1) call s:InitVariable('g:NERDAllowAnyVisualDelims', 1)
call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0) call s:InitVariable('g:NERDBlockComIgnoreEmpty', 0)
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0) call s:InitVariable('g:NERDCommentWholeLinesInVMode', 0)
call s:InitVariable("g:NERDCommentEmptyLines", 0) call s:InitVariable('g:NERDCommentEmptyLines', 0)
call s:InitVariable("g:NERDCompactSexyComs", 0) call s:InitVariable('g:NERDCompactSexyComs', 0)
call s:InitVariable("g:NERDCreateDefaultMappings", 1) call s:InitVariable('g:NERDCreateDefaultMappings', 1)
call s:InitVariable("g:NERDDefaultNesting", 1) call s:InitVariable('g:NERDDefaultNesting', 1)
call s:InitVariable("g:NERDMenuMode", 3) call s:InitVariable('g:NERDMenuMode', 3)
call s:InitVariable("g:NERDLPlace", "[>") call s:InitVariable('g:NERDLPlace', '[>')
call s:InitVariable("g:NERDUsePlaceHolders", 1) call s:InitVariable('g:NERDUsePlaceHolders', 1)
call s:InitVariable("g:NERDRemoveAltComs", 1) call s:InitVariable('g:NERDRemoveAltComs', 1)
call s:InitVariable("g:NERDRemoveExtraSpaces", 0) call s:InitVariable('g:NERDRemoveExtraSpaces', 0)
call s:InitVariable("g:NERDRPlace", "<]") call s:InitVariable('g:NERDRPlace', '<]')
call s:InitVariable("g:NERDSpaceDelims", 0) call s:InitVariable('g:NERDSpaceDelims', 0)
call s:InitVariable("g:NERDDefaultAlign", "none") call s:InitVariable('g:NERDDefaultAlign', 'none')
call s:InitVariable("g:NERDTrimTrailingWhitespace", 0) call s:InitVariable('g:NERDTrimTrailingWhitespace', 0)
call s:InitVariable("g:NERDToggleCheckAllLines", 0) call s:InitVariable('g:NERDToggleCheckAllLines', 0)
call s:InitVariable("g:NERDDisableTabsInBlockComm", 0) call s:InitVariable('g:NERDDisableTabsInBlockComm', 0)
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
@ -320,7 +320,7 @@ let s:delimiterMap = {
\ 'omnimark': { 'left': ';' }, \ 'omnimark': { 'left': ';' },
\ 'ooc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'ooc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'openroad': { 'left': '//' }, \ 'openroad': { 'left': '//' },
\ 'opl': { 'left': "REM" }, \ 'opl': { 'left': 'REM' },
\ 'ora': { 'left': '#' }, \ 'ora': { 'left': '#' },
\ 'ox': { 'left': '//' }, \ 'ox': { 'left': '//' },
\ 'paludis-use-conf': { 'left': '#' }, \ 'paludis-use-conf': { 'left': '#' },
@ -442,14 +442,14 @@ let s:delimiterMap = {
\ 'teak': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'teak': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tex': { 'left': '%' }, \ 'tex': { 'left': '%' },
\ 'texinfo': { 'left': "@c " }, \ 'texinfo': { 'left': '@c ' },
\ 'texmf': { 'left': '%' }, \ 'texmf': { 'left': '%' },
\ 'tf': { 'left': '#' }, \ 'tf': { 'left': '#' },
\ 'tidy': { 'left': '#' }, \ 'tidy': { 'left': '#' },
\ 'tli': { 'left': '#' }, \ 'tli': { 'left': '#' },
\ 'tmux': { 'left': '#' }, \ 'tmux': { 'left': '#' },
\ 'toml': { 'left': '#' }, \ 'toml': { 'left': '#' },
\ 'trasys': { 'left': "$" }, \ 'trasys': { 'left': '$' },
\ 'troff': { 'left': '.\\"' }, \ 'troff': { 'left': '.\\"' },
\ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'tsscl': { 'left': '#' }, \ 'tsscl': { 'left': '#' },
@ -466,7 +466,7 @@ let s:delimiterMap = {
\ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'vasp': { 'left': '!' }, \ 'vasp': { 'left': '!' },
\ 'vb': { 'left': "'" }, \ 'vb': { 'left': "'" },
\ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' }, \ 'velocity': { 'left': '##', 'right': '', 'leftAlt': '#*', 'rightAlt': '*#' },
\ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, \ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' },
\ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
\ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
@ -493,7 +493,7 @@ let s:delimiterMap = {
let g:NERDDelimiterMap = s:delimiterMap let g:NERDDelimiterMap = s:delimiterMap
if exists("g:NERDCustomDelimiters") if exists('g:NERDCustomDelimiters')
call extend(s:delimiterMap, g:NERDCustomDelimiters) call extend(s:delimiterMap, g:NERDCustomDelimiters)
endif endif
@ -553,7 +553,7 @@ function s:SetUpForNewFiletype(filetype, forceReset)
endif endif
endfor endfor
" if g:NERD_<filetype>_alt_style is defined, use the alternate style " if g:NERD_<filetype>_alt_style is defined, use the alternate style
let b:NERDCommenterFirstInit = getbufvar(1,"NERDCommenterFirstInit") let b:NERDCommenterFirstInit = getbufvar(1,'NERDCommenterFirstInit')
if exists('g:NERDAltDelims_'.ft) && eval('g:NERDAltDelims_'.ft) && !b:NERDCommenterFirstInit if exists('g:NERDAltDelims_'.ft) && eval('g:NERDAltDelims_'.ft) && !b:NERDCommenterFirstInit
call s:SwitchToAlternativeDelimiters(0) call s:SwitchToAlternativeDelimiters(0)
let b:NERDCommenterFirstInit = 1 let b:NERDCommenterFirstInit = 1
@ -594,13 +594,13 @@ endfunction
" if this function changed the delimiters or not " if this function changed the delimiters or not
function s:SwitchToAlternativeDelimiters(printMsgs) function s:SwitchToAlternativeDelimiters(printMsgs)
if exists('*NERDCommenter_before') if exists('*NERDCommenter_before')
exe "call NERDCommenter_before()" exe 'call NERDCommenter_before()'
endif endif
"if both of the alternative delimiters are empty then there is no "if both of the alternative delimiters are empty then there is no
"alternative comment style so bail out "alternative comment style so bail out
if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == '' if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == ''
if a:printMsgs if a:printMsgs
call s:NerdEcho("Cannot use alternative delimiters, none are specified", 0) call s:NerdEcho('Cannot use alternative delimiters, none are specified', 0)
endif endif
return 0 return 0
endif endif
@ -623,11 +623,11 @@ function s:SwitchToAlternativeDelimiters(printMsgs)
"tell the user what comment delimiters they are now using "tell the user what comment delimiters they are now using
if a:printMsgs if a:printMsgs
call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1) call s:NerdEcho('Now using ' . s:Left() . ' ' . s:Right() . ' to delimit comments', 1)
endif endif
if exists('*NERDCommenter_after') if exists('*NERDCommenter_after')
exe "call NERDCommenter_after()" exe 'call NERDCommenter_after()'
endif endif
return 1 return 1
@ -645,18 +645,18 @@ function s:AppendCommentToLine()
" get the length of the right delimiter " get the length of the right delimiter
let lenRight = strlen(right) let lenRight = strlen(right)
let isLineEmpty = strlen(getline(".")) == 0 let isLineEmpty = strlen(getline('.')) == 0
let insOrApp = (isLineEmpty==1 ? 'i' : 'A') let insOrApp = (isLineEmpty==1 ? 'i' : 'A')
"stick the delimiters down at the end of the line. We have to format the "stick the delimiters down at the end of the line. We have to format the
"comment with spaces as appropriate "comment with spaces as appropriate
execute ":normal! " . insOrApp . (isLineEmpty ? '' : ' ') . left . right execute ':normal! ' . insOrApp . (isLineEmpty ? '' : ' ') . left . right
" if there is a right delimiter then we gotta move the cursor left " if there is a right delimiter then we gotta move the cursor left
" by the length of the right delimiter so we insert between the delimiters " by the length of the right delimiter so we insert between the delimiters
if lenRight > 0 if lenRight > 0
let leftMoveAmount = lenRight - 1 let leftMoveAmount = lenRight - 1
execute ":normal! " . leftMoveAmount . "h" execute ':normal! ' . leftMoveAmount . 'h'
startinsert startinsert
else else
startinsert! startinsert!
@ -809,7 +809,7 @@ 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
let leftAlignIndx = a:align == "start" ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let leftAlignIndx = a:align == 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
" gotta add the length of the left delimiter onto the rightAlignIndx cos " gotta add the length of the left delimiter onto the rightAlignIndx cos
@ -837,12 +837,12 @@ function s:CommentLines(forceNested, align, 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:align == "left" || a:align == "start" || a:align == "both" if a:align == 'left' || a:align == 'start' || a:align == 'both'
let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx)
else else
let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
endif endif
if a:align == "both" if a:align == 'both'
let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx)
else else
let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine)
@ -1073,7 +1073,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine)
let currentLine = a:firstLine let currentLine = a:firstLine
let align = g:NERDDefaultAlign let align = g:NERDDefaultAlign
let leftAlignIndx = align == "start" ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let leftAlignIndx = align == 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine)
let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1})) let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1}))
@ -1096,7 +1096,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine)
else else
let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
endif endif
if align == "both" if align == 'both'
let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx)
else else
let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine)
@ -1225,13 +1225,13 @@ endfunction
" 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' " 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank'
function! NERDComment(mode, type) range function! NERDComment(mode, type) range
if exists('*NERDCommenter_before') if exists('*NERDCommenter_before')
exe "call NERDCommenter_before()" exe 'call NERDCommenter_before()'
endif endif
let isVisual = a:mode =~ '[vsx]' let isVisual = a:mode =~ '[vsx]'
if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1 if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1
call s:NerdEcho("filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on", 0) call s:NerdEcho('filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on', 0)
endif endif
if isVisual if isVisual
@ -1254,18 +1254,18 @@ function! NERDComment(mode, type) range
if a:type ==? 'Comment' || a:type ==? 'Nested' if a:type ==? 'Comment' || a:type ==? 'Nested'
if isVisual && visualmode() == "\<C-V>" if isVisual && visualmode() == "\<C-V>"
call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested) call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested)
elseif isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims())) elseif 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, g:NERDDefaultAlign, firstLine, lastLine) call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine)
endif endif
elseif a:type ==? 'AlignLeft' || a:type ==? 'AlignBoth' elseif a:type ==? 'AlignLeft' || a:type ==? 'AlignBoth'
let align = "none" let align = 'none'
if a:type ==? "AlignLeft" if a:type ==? 'AlignLeft'
let align = "left" let align = 'left'
elseif a:type ==? "AlignBoth" elseif a:type ==? 'AlignBoth'
let align = "both" let align = 'both'
endif endif
call s:CommentLines(forceNested, align, firstLine, lastLine) call s:CommentLines(forceNested, align, firstLine, lastLine)
@ -1278,7 +1278,7 @@ function! NERDComment(mode, type) range
catch /NERDCommenter.Delimiters/ catch /NERDCommenter.Delimiters/
call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine) call s:CommentLines(forceNested, g:NERDDefaultAlign, 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
elseif a:type ==? 'Toggle' elseif a:type ==? 'Toggle'
@ -1311,14 +1311,14 @@ function! NERDComment(mode, type) range
try try
call s:CommentLinesMinimal(firstLine, lastLine) call s:CommentLinesMinimal(firstLine, lastLine)
catch /NERDCommenter.Delimiters/ catch /NERDCommenter.Delimiters/
call s:NerdEcho("Minimal comments can only be used for filetypes that have multipart delimiters.", 0) call s:NerdEcho('Minimal comments can only be used for filetypes that have multipart delimiters.', 0)
catch /NERDCommenter.Settings/ catch /NERDCommenter.Settings/
call s:NerdEcho("Place holders are required but disabled.", 0) call s:NerdEcho('Place holders are required but disabled.', 0)
endtry endtry
elseif a:type ==? 'ToEOL' elseif a:type ==? 'ToEOL'
call s:SaveScreenState() call s:SaveScreenState()
call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1) call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1)
call s:RestoreScreenState() call s:RestoreScreenState()
elseif a:type ==? 'Append' elseif a:type ==? 'Append'
@ -1345,13 +1345,13 @@ function! NERDComment(mode, type) range
if isVisual if isVisual
let nlines = lastLine - firstLine let nlines = lastLine - firstLine
silent! call repeat#set("V" . nlines . "jo" . "\<Plug>NERDCommenter". a:type) silent! call repeat#set('V' . nlines . 'jo' . "\<Plug>NERDCommenter". a:type)
else else
silent! call repeat#set("\<Plug>NERDCommenter". a:type) silent! call repeat#set("\<Plug>NERDCommenter". a:type)
endif endif
if exists('*NERDCommenter_after') if exists('*NERDCommenter_after')
exe "call NERDCommenter_after()" exe 'call NERDCommenter_after()'
endif endif
endfunction endfunction
@ -1364,40 +1364,40 @@ function s:PlaceDelimitersAndInsBetween()
let left = s:Left({'space': 1}) let left = s:Left({'space': 1})
let right = s:Right({'space': 1}) let right = s:Right({'space': 1})
let theLine = getline(".") let theLine = getline('.')
let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~ '^ *$' && !&expandtab) let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~ '^ *$' && !&expandtab)
"convert tabs to spaces and adjust the cursors column to take this into "convert tabs to spaces and adjust the cursors column to take this into
"account "account
let untabbedCol = s:UntabbedCol(theLine, col(".")) let untabbedCol = s:UntabbedCol(theLine, col('.'))
call setline(line("."), s:ConvertLeadingTabsToSpaces(theLine)) call setline(line('.'), s:ConvertLeadingTabsToSpaces(theLine))
call cursor(line("."), untabbedCol) call cursor(line('.'), untabbedCol)
" get the length of the right delimiter " get the length of the right delimiter
let lenRight = strlen(right) let lenRight = strlen(right)
let isDelimOnEOL = col(".") >= strlen(getline(".")) let isDelimOnEOL = col('.') >= strlen(getline('.'))
" if the cursor is in the first col then we gotta insert rather than " if the cursor is in the first col then we gotta insert rather than
" append the comment delimiters here " append the comment delimiters here
let insOrApp = (col(".")==1 ? 'i' : 'a') let insOrApp = (col('.')==1 ? 'i' : 'a')
" place the delimiters down. We do it differently depending on whether " place the delimiters down. We do it differently depending on whether
" there is a left AND right delimiter " there is a left AND right delimiter
if lenRight > 0 if lenRight > 0
execute ":normal! " . insOrApp . left . right execute ':normal! ' . insOrApp . left . right
execute ":normal! " . lenRight . "h" execute ':normal! ' . lenRight . 'h'
else else
execute ":normal! " . insOrApp . left execute ':normal! ' . insOrApp . left
endif endif
silent! normal! l silent! normal! l
"if needed convert spaces back to tabs and adjust the cursors col "if needed convert spaces back to tabs and adjust the cursors col
"accordingly "accordingly
if lineHasLeadTabs if lineHasLeadTabs
let tabbedCol = s:TabbedCol(getline("."), col(".")) let tabbedCol = s:TabbedCol(getline('.'), col('.'))
call setline(line("."), s:ConvertLeadingSpacesToTabs(getline("."))) call setline(line('.'), s:ConvertLeadingSpacesToTabs(getline('.')))
call cursor(line("."), tabbedCol) call cursor(line('.'), tabbedCol)
endif endif
if isDelimOnEOL && lenRight == 0 if isDelimOnEOL && lenRight == 0
@ -1412,7 +1412,7 @@ endfunction
" last right delimiter of the given line. " last right delimiter of the given line.
" "
" The arguments left and right must be strings. If there is no right delimiter (as " The arguments left and right must be strings. If there is no right delimiter (as
" is the case for e.g vim file comments) them the argument right should be "" " is the case for e.g vim file comments) them the argument right should be ''
" "
" Args: " Args:
" -left: the left comment delimiter " -left: the left comment delimiter
@ -1475,7 +1475,7 @@ function s:SetupStateBeforeLineComment(topLine, bottomLine)
" manual, do the commenting stuff and recover it later. To avoid slowing " manual, do the commenting stuff and recover it later. To avoid slowing
" down commenting few lines, we avoid doing this for ranges smaller than " down commenting few lines, we avoid doing this for ranges smaller than
" 10 lines " 10 lines
if a:bottomLine - a:topLine >= 10 && &foldmethod != "manual" if a:bottomLine - a:topLine >= 10 && &foldmethod != 'manual'
set foldmethod=manual set foldmethod=manual
endif endif
@ -1814,7 +1814,7 @@ endfunction
" Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2 " Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2
" Args: " Args:
function s:AddRightDelimAligned(delim, theLine, alignIndx) function s:AddRightDelimAligned(delim, theLine, alignIndx)
if a:delim == "" if a:delim == ''
return a:theLine return a:theLine
else else
@ -1881,10 +1881,10 @@ endfunction
" Function: s:CanPlaceCursor(line, col) {{{2 " Function: s:CanPlaceCursor(line, col) {{{2
" returns 1 if the cursor can be placed exactly in the given position " returns 1 if the cursor can be placed exactly in the given position
function s:CanPlaceCursor(line, col) function s:CanPlaceCursor(line, col)
let c = col(".") let c = col('.')
let l = line(".") let l = line('.')
call cursor(a:line, a:col) call cursor(a:line, a:col)
let success = (line(".") == a:line && col(".") == a:col) let success = (line('.') == a:line && col('.') == a:col)
call cursor(l,c) call cursor(l,c)
return success return success
endfunction endfunction
@ -1942,7 +1942,7 @@ endfunction
function s:ConvertLeadingSpacesToTabs(line) function s:ConvertLeadingSpacesToTabs(line)
let toReturn = a:line let toReturn = a:line
while toReturn =~ '^\t*' . s:TabSpace() . '\(.*\)$' while toReturn =~ '^\t*' . s:TabSpace() . '\(.*\)$'
let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , "") let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , '')
endwhile endwhile
return toReturn return toReturn
@ -1958,7 +1958,7 @@ endfunction
function s:ConvertLeadingTabsToSpaces(line) function s:ConvertLeadingTabsToSpaces(line)
let toReturn = a:line let toReturn = a:line
while toReturn =~ '^\( *\)\t' while toReturn =~ '^\( *\)\t'
let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , "") let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , '')
endwhile endwhile
return toReturn return toReturn
@ -1972,7 +1972,7 @@ endfunction
function s:ConvertLeadingWhiteSpace(line) function s:ConvertLeadingWhiteSpace(line)
let toReturn = a:line let toReturn = a:line
while toReturn =~ '^ *\t' while toReturn =~ '^ *\t'
let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), "g") let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), 'g')
endwhile endwhile
if !&expandtab if !&expandtab
@ -2062,7 +2062,7 @@ endfunction
function s:FindDelimiterIndex(delimiter, line) function s:FindDelimiterIndex(delimiter, line)
"make sure the delimiter isn't empty otherwise we go into an infinite loop. "make sure the delimiter isn't empty otherwise we go into an infinite loop.
if a:delimiter == "" if a:delimiter == ''
return -1 return -1
endif endif
@ -2474,13 +2474,13 @@ function s:IsDelimValid(delimiter, delIndx, line)
"to check if the delimiter is real, make sure it isn't preceded by "to check if the delimiter is real, make sure it isn't preceded by
"an odd number of quotes and followed by the same (which would indicate "an odd number of quotes and followed by the same (which would indicate
"that it is part of a string and therefore is not a comment) "that it is part of a string and therefore is not a comment)
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '"', "\\")) if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '"', '\\'))
return 0 return 0
endif endif
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "'", "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "'", "\\")) if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "'", '\\')) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "'", '\\'))
return 0 return 0
endif endif
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "`", "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "`", "\\")) if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '`', '\\')) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '`', '\\'))
return 0 return 0
endif endif
@ -2493,7 +2493,7 @@ function s:IsDelimValid(delimiter, delIndx, line)
"vim comments are so fucking stupid!! Why the hell do they have comment "vim comments are so fucking stupid!! Why the hell do they have comment
"delimiters that are used elsewhere in the syntax?!?! We need to check "delimiters that are used elsewhere in the syntax?!?! We need to check
"some conditions especially for vim "some conditions especially for vim
if &filetype == "vim" if &filetype == 'vim'
if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\"))
return 0 return 0
endif endif
@ -2504,8 +2504,8 @@ function s:IsDelimValid(delimiter, delIndx, line)
return 1 return 1
endif endif
let numLeftParen =s:CountNonESCedOccurances(preComStr, "(", "\\") let numLeftParen =s:CountNonESCedOccurances(preComStr, '(', '\\')
let numRightParen =s:CountNonESCedOccurances(preComStr, ")", "\\") let numRightParen =s:CountNonESCedOccurances(preComStr, ')', '\\')
"if the quote is inside brackets then assume it isn't a comment "if the quote is inside brackets then assume it isn't a comment
if numLeftParen > numRightParen if numLeftParen > numRightParen
@ -2514,7 +2514,7 @@ function s:IsDelimValid(delimiter, delIndx, line)
"if the line has an even num of unescaped "'s then we can assume that "if the line has an even num of unescaped "'s then we can assume that
"any given " is not a comment delimiter "any given " is not a comment delimiter
if s:IsNumEven(s:CountNonESCedOccurances(a:line, "\"", "\\")) if s:IsNumEven(s:CountNonESCedOccurances(a:line, '"', '\\'))
return 0 return 0
endif endif
endif endif
@ -2781,7 +2781,7 @@ endfunction
" Function: s:NumberOfLeadingTabs(s) {{{2 " Function: s:NumberOfLeadingTabs(s) {{{2
" returns the number of leading tabs in the given string " returns the number of leading tabs in the given string
function s:NumberOfLeadingTabs(s) function s:NumberOfLeadingTabs(s)
return strlen(substitute(a:s, '^\(\t*\).*$', '\1', "")) return strlen(substitute(a:s, '^\(\t*\).*$', '\1', ''))
endfunction endfunction
" Function: s:NumLinesInBuf() {{{2 " Function: s:NumLinesInBuf() {{{2
@ -2861,13 +2861,13 @@ endfunction
"called. "called.
" "
function s:RestoreScreenState() function s:RestoreScreenState()
if !exists("t:NERDComOldTopLine") || !exists("t:NERDComOldPos") if !exists('t:NERDComOldTopLine') || !exists('t:NERDComOldPos')
throw 'NERDCommenter exception: cannot restore screen' throw 'NERDCommenter exception: cannot restore screen'
endif endif
call cursor(t:NERDComOldTopLine, 0) call cursor(t:NERDComOldTopLine, 0)
normal! zt normal! zt
call setpos(".", t:NERDComOldPos) call setpos('.', t:NERDComOldPos)
endfunction endfunction
" Function: s:Right(...) {{{2 " Function: s:Right(...) {{{2
@ -2935,8 +2935,8 @@ endfunction
"Saves the current cursor position in the current buffer and the window "Saves the current cursor position in the current buffer and the window
"scroll position "scroll position
function s:SaveScreenState() function s:SaveScreenState()
let t:NERDComOldPos = getpos(".") let t:NERDComOldPos = getpos('.')
let t:NERDComOldTopLine = line("w0") let t:NERDComOldTopLine = line('w0')
endfunction endfunction
" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) {{{2 " Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) {{{2
@ -3001,10 +3001,10 @@ endfunction
"FUNCTION: s:TabSpace() {{{2 "FUNCTION: s:TabSpace() {{{2
"returns a string of spaces equal in length to &tabstop "returns a string of spaces equal in length to &tabstop
function s:TabSpace() function s:TabSpace()
let tabSpace = "" let tabSpace = ''
let spacesPerTab = &tabstop let spacesPerTab = &tabstop
while spacesPerTab > 0 while spacesPerTab > 0
let tabSpace = tabSpace . " " let tabSpace = tabSpace . ' '
let spacesPerTab = spacesPerTab - 1 let spacesPerTab = spacesPerTab - 1
endwhile endwhile
return tabSpace return tabSpace
@ -3016,7 +3016,7 @@ endfunction
" -str: the string to remove esc chars from " -str: the string to remove esc chars from
" -escChar: the escape char to be removed " -escChar: the escape char to be removed
function s:UnEsc(str, escChar) function s:UnEsc(str, escChar)
return substitute(a:str, a:escChar, "", "g") return substitute(a:str, a:escChar, '', 'g')
endfunction endfunction
" Function: s:UntabbedCol(line, col) {{{2 " Function: s:UntabbedCol(line, col) {{{2
@ -3084,7 +3084,7 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '')
call s:CreateMaps('', ':', '-Sep3-', '') call s:CreateMaps('', ':', '-Sep3-', '')
call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '') call s:CreateMaps('', ':help NERDCommenterContents<CR>', 'Help', '')
inoremap <silent> <plug>NERDCommenterInsert <SPACE><BS><ESC>:call NERDComment('i', "insert")<CR> inoremap <silent> <plug>NERDCommenterInsert <SPACE><BS><ESC>:call NERDComment('i', 'insert')<CR>
" switch to/from alternative delimiters (does not use wrapper function) " switch to/from alternative delimiters (does not use wrapper function)
nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr> nnoremap <plug>NERDCommenterAltDelims :call <SID>SwitchToAlternativeDelimiters(1)<cr>