0
下面的代码已从this blogVIM codewalk通过
function! Privatize()
let priorMethod = PriorMethodDefinition()
exec "normal iprivate :" . priorMethod . "\<Esc>=="
endfunction
function! PriorMethodDefinition()
let lineNumber = search('def', 'bn')
let line = getline(lineNumber)
if line == 0
echo "No prior method definition found"
endif
return matchlist(line, 'def \(\w\+\).*')[1]
endfunction
map <Leader>p :call Privatize()<CR>
我试着拿起,但我不明白PriorMethodDefinition方法。有人可以通过这段代码走过我吗?
真棒。你的回答给了我一些指示,开始阅读vim的书。谢谢。 – 2010-12-06 23:43:32