An expansion of this question: How can I highlight all function names in Python files?
i have a sample:
src_file = replacement_file.replace(header_dir, source_dir)
here i need to match variable/arguments inside method/function, i need to match "header_dir", "source_dir"
Any suggestion is highly appreciated.
I'm working on the problem so will feedback to you via edit. thanks.
Edit 1: i try to match the function name, with help of @carpetsmoker i can match function name but can't match inside (), here:
syn match pFun "\v[[:alpha:]_.]+\ze(\s?\()" contained nextgroup=pFunVars syn region pFunVars start="(" end=")" contained contains=pFunPara transparent keepend syn match pFunPara "[^,]*" contained contains=pythonString,pythonBrackets skipwhite
it doesn't match both function name and variables. highlight completely failed.
the fact is if i keep only:
syn match pFun "\v[[:alpha:]_.]+\ze(\s?\()"
function name match works. any clues?
EDIT 2: i guess match with end is ( and a region that start with "(" make it confused by regex engine. question is how can i separate the match pattern from ending with (, pattern contains ( and start of region is (, is that double "(" ?
EDIT 3: thanks @muru for suggestion, but it works partially,
syn region pFun matchgroup=Function \start="\v[[:alpha:]_.]+\ze(\s?\()" end=")" contains=pFun nextgroup=pFunPara syn match pFunPara /\i*\ze\s*=[^,]/ contained contains=pythonString,pythonBrackets skipwhite
here, "pFunPara /\i*\ze\s*=[^,]/" i can't highlight the contains: pythonString, pythonBrackets inside pFunPara, @muru, do you have pattern to improve this? maybe loop via pFun make it impossible to highlight?