I'd like to write a function in vimscript that finds the last open parenthese or bracket in a line. This isn't necessarily an easy problem, because it needs to be able to handle all of the following:
function(abc
function(abc, [def
function(abc, [def], "string("
function(abc, [def], "string(", ghi(
As you can see, nested parenthesis, differing symbols, and string tokens all need to be handled intelligently. Is this even possible? Are there tools with vimscript regexes to do context-aware searches that know the difference between unclosed parentheses and parenthesis in strings?
Given that you can syntax highlight unbalanced brackets, it should be possible to find the last unclosed parenthese/bracket on a line. How can this be done?