Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy code with full package names

Sometimes I want to copy a random block of my code that uses 3rd party libraries and share it with others. e.g., Put it on a blog or something. If I paste what I copy, a lot of context is lost because you can't see the packages of the 3rd party libraries.

The solution I use is to reduce this code into a small class and then share the whole class, import statements and all. This is a lot of manual work, especially if it's just for a simple email to someone. Is there a way I can copy a snippet of code and have it include the full package paths?

like image 277
Daniel Kaplan Avatar asked Dec 06 '25 03:12

Daniel Kaplan


1 Answers

You probably can use Scratch File (Ctrl-Alt-Shift-Insert) and copy-paste to it so imports should be copied too. It's a bit faster than copy-paste to new file.

like image 182
Sergey Mashkov Avatar answered Dec 08 '25 19:12

Sergey Mashkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!