Skip to content

Instantly share code, notes, and snippets.

@kana
Created December 20, 2010 15:34
Show Gist options
  • Save kana/748514 to your computer and use it in GitHub Desktop.
Save kana/748514 to your computer and use it in GitHub Desktop.
" perl: add 'use' statement for package name under the cursor
function! AddUse()
let line = line('.')
let col = col('.')
normal! yiw
let default = @"
let package = input('Package? ', default)
if (search('^use '.package, 'bnw') == 0)
call search('^use ','b')
put ='use ' . package . ';'
call cursor(line+1,col)
endif
endfunction
noremap ,us :call AddUse()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment