mirror of
https://github.com/preservim/nerdcommenter.git
synced 2025-11-09 18:23:48 -05:00
substitute(.., '..\(pat\)..', '\1') → matchstr()
This commit is contained in:
@@ -506,8 +506,8 @@ function! s:CreateDelimMapFromCms() abort
|
|||||||
return delims
|
return delims
|
||||||
endif
|
endif
|
||||||
return {
|
return {
|
||||||
\ 'left': substitute(&commentstring, '\(\S*\)\s*%s.*', '\1', ''),
|
\ 'left': matchstr(&commentstring, '^\S*\ze\s*%s'),
|
||||||
\ 'right': substitute(&commentstring, '.*%s\s*\(.*\)', '\1', 'g'),
|
\ 'right': matchstr(&commentstring, '%s\s*\zs.*$'),
|
||||||
\ 'nested': 0,
|
\ 'nested': 0,
|
||||||
\ 'leftAlt': '',
|
\ 'leftAlt': '',
|
||||||
\ 'rightAlt': '',
|
\ 'rightAlt': '',
|
||||||
@@ -1091,7 +1091,7 @@ function! s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) a
|
|||||||
|
|
||||||
"comment the bottom line
|
"comment the bottom line
|
||||||
let bottom = getline(a:bottomLine)
|
let bottom = getline(a:bottomLine)
|
||||||
let numLeadingSpacesTabs = strlen(substitute(bottom, '^\(\s*\).*$', '\1', ''))
|
let numLeadingSpacesTabs = strlen(matchstr(bottom, '^\s*'))
|
||||||
call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
|
call s:CommentBlock(a:bottomLine, a:bottomLine, numLeadingSpacesTabs+1, a:bottomCol, a:forceNested)
|
||||||
|
|
||||||
endif
|
endif
|
||||||
@@ -2450,7 +2450,7 @@ endfunction
|
|||||||
" -left: the left delimiter to check for
|
" -left: the left delimiter to check for
|
||||||
function! s:IsCommentedFromStartOfLine(left, line) abort
|
function! s:IsCommentedFromStartOfLine(left, line) abort
|
||||||
let theLine = s:ConvertLeadingTabsToSpaces(a:line)
|
let theLine = s:ConvertLeadingTabsToSpaces(a:line)
|
||||||
let numSpaces = strlen(substitute(theLine, '^\( *\).*$', '\1', ''))
|
let numSpaces = strlen(matchstr(theLine, '^ *'))
|
||||||
let delimIndx = s:FindDelimiterIndex(a:left, theLine)
|
let delimIndx = s:FindDelimiterIndex(a:left, theLine)
|
||||||
return delimIndx ==# numSpaces
|
return delimIndx ==# numSpaces
|
||||||
endfunction
|
endfunction
|
||||||
@@ -2785,7 +2785,7 @@ function! s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomli
|
|||||||
" convert spaces to tabs and get the number of leading spaces for
|
" convert spaces to tabs and get the number of leading spaces for
|
||||||
" this line and update leftMostIndx if need be
|
" this line and update leftMostIndx if need be
|
||||||
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
|
let theLine = s:ConvertLeadingTabsToSpaces(theLine)
|
||||||
let leadSpaceOfLine = strlen( substitute(theLine, '\(^\s*\).*$','\1','') )
|
let leadSpaceOfLine = strlen(matchstr(theLine, '^\s*'))
|
||||||
if leadSpaceOfLine < leftMostIndx
|
if leadSpaceOfLine < leftMostIndx
|
||||||
let leftMostIndx = leadSpaceOfLine
|
let leftMostIndx = leadSpaceOfLine
|
||||||
endif
|
endif
|
||||||
@@ -2833,7 +2833,7 @@ endfunction
|
|||||||
" Function: s:NumberOfLeadingTabs(s)
|
" Function: s:NumberOfLeadingTabs(s)
|
||||||
" returns the number of leading tabs in the given string
|
" returns the number of leading tabs in the given string
|
||||||
function! s:NumberOfLeadingTabs(s) abort
|
function! s:NumberOfLeadingTabs(s) abort
|
||||||
return strlen(substitute(a:s, '^\(\t*\).*$', '\1', ''))
|
return strlen(matchstr(a:s, '^\t*'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Function: s:NumLinesInBuf()
|
" Function: s:NumLinesInBuf()
|
||||||
|
|||||||
Reference in New Issue
Block a user