public
Created

  • Download Gist
hanekomu.vim
VimL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
nnoremap <Leader>pa :<C-u>call PerlReplacePackageName()<CR>
 
function! PerlPackageNameFromFile()
let filename = expand('%:p')
let package = substitute(filename, '^.*/lib/', '', '')
let package = substitute(package, '\.pm$', '', '')
let package = substitute(package, '/', '::', 'g')
return package
endfunction
 
function! PerlReplacePackageName()
let package = PerlPackageNameFromFile()
let pos = getpos('.')
1,/^package\s/s/^package\s\+\zs[A-Za-z_0-9:]\+\ze\(\s\+{\|;\)/\=package/
call setpos('.', pos)
endfunction

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.