Is there a way to copy code from eclipse including ine numbers

强颜欢笑 提交于 2019-12-01 16:25:17

问题


I am writing a little bit of documentation and code explanation. I would like to copy code from eclipse including line numbers, so that it becomes easier to reference the code in the text.

Is there any way to do this in eclipse or some other IDE, editor?


回答1:


Since Eclipse 3.4 and bug 19602, you will print the line numbers if you have activated them on the Eclipse editor.

alt text http://img706.imageshack.us/img706/7605/eclipseshowlines.png

Printing a source will give you:

alt text http://img341.imageshack.us/img341/9899/eclipseprint.png




回答2:


You can do it by printing a PDF of source file, then copying source with line numbers from the PDF document.

It works for me with eclipse PDT + CutePDF, it should also work with Acrobat PDF printer




回答3:


Another not-so-clean work-around to achieve this. This is specific to the Subversive plug-in.

3 steps to follow:

  1. Delete the piece of code you need to copy and save the source file.
  2. Right click the file and chose option Team -> Create Patch.. and save it to a file, say copy.patch
  3. Undo (Ctrl + Z) the changes to revert the deletion done in step 1 and save the source file again.

Open the patch file and use the contents.

This also includes the file-name (if desired) along with the line number and retains the indentation.



来源:https://stackoverflow.com/questions/2873201/is-there-a-way-to-copy-code-from-eclipse-including-ine-numbers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!