vim9script setlocal shiftwidth=2 call custom#undo_ftplugin#Set('setl sw<') def InsideTag(tagname: string): bool const open_tag = '<' .. tagname .. '\>' const close_tag = '' if searchpair(open_tag, '', close_tag, 'nW') > 0 if match(getline('.'), '^\s*' .. open_tag) == -1 return true endif endif return false enddef def SetCommentString() if InsideTag('script') &l:commentstring = '//%s' elseif InsideTag('style') &l:commentstring = '/*%s*/' else &l:commentstring = '' endif enddef xmap gc SetCommentString()Commentary nmap gc SetCommentString()Commentary omap gc SetCommentString()Commentary nmap gcc SetCommentString()CommentaryLine nmap gcu SetCommentString()CommentaryCommentary