Skip to content
Create a gist now

Instantly share code, notes, and snippets.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.