Ask coding questions

← Back to all posts
Copying code with line numbers
JoeEnglish (0)

Is there a way to copy code including line numbers? (I want to paste into Word)

mwilki7 (786)

If you have AutoHotKey installed, run this script:
Copy paste the code in a text file first

line := 1
while GetKeyState("F1", "P")
     Send {home}
     Send %line%
     Send {space}
     Send {down}
     line := line + 1

Make sure your cursor is at the beginning of the file and hold F1 until you reach the end of the file.

Zavexeon (927)

Try making a numbered list and then copying and pasting?