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)

Commentshotnewtop
mwilki7 (203)

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

line := 1
$F1::
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 (303)

Try making a numbered list and then copying and pasting?