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 = @0
let package = input('Package? ', default)
if (search('^use\s\+'.package, 'bnw') == 0)
call search('^use\s\+', 'b')
put ='use ' . package . ';'
call cursor(line+1, col)
endif
endfunction
nnoremap ,us :<C-u>call AddUse()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment