Skip to content

Instantly share code, notes, and snippets.

@gavinwahl
Created November 8, 2012 20:12
Show Gist options
  • Save gavinwahl/4041240 to your computer and use it in GitHub Desktop.
Save gavinwahl/4041240 to your computer and use it in GitHub Desktop.
python super call snippet
snippet sup
super(`GetCurrentPythonClass()`, `GetFirstPythonArg()`).`GetCurrentPythonMethod()`(${1:`GetCurrentPythonArgs()`})${2}
function! GetCurrentPythonClass()
call search('^\s*class \ze\S\+\s*(', 'sbe')
let class = expand('<cword>')
normal ''
return class
endfunction
function! GetCurrentPythonMethod()
call search('^\s*def ', 'sbe')
let method = expand('<cword>')
normal ''
return method
endfunction
function! GetFirstPythonArg()
call search('^\s*def \S\+(', 'sbe')
let method = expand('<cword>')
normal ''
return method
endfunction
function! GetCurrentPythonArgs()
let line_number = search('^\s*def[^(]\+([^,]*,\?', 'sbe')
echo line_number
let args = matchstr(getline(line_number), '^\s*def[^(]\+([^,]\+,\s*\zs.*\ze):$')
let args = substitute(args, '\s*=[^,]\+', '', 'g')
normal ''
return args
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment