Line numbers for code in MS Word

Good evening folks,

I am in need of some support, regarding a bunch of codes I have to document in MS Word. As I see screen caps as a last result, I tried some of the solutions on stack overflow. After opening my code in Notepad++, I copied it to clipboard as RTF and pasted it into a text box. For some reason, the background became all yellow, so I removed that. Then I tried to add some line numbers, removed the dots and changed the font and size to match the code. It looked really nice, until I tried some code with indentation. Well, as you can see, it didn't work out too well. Is there anything I can do, besides replacing the tabulator with some spaces? And in that case, how many?

Answers are appreciated!

As you can clearly see, I failed at line three.

Answer
Answer

You need to follow the steps in the second paragraph of my initial response.

With the following code in a Textbox

and the option set under File>Options>Proofing>AutoCorrecct Options...>AutoFormat As You Type for left- and first-indent to be set with tabs and backspaces

pressing tab in the third line of code results in

However, if the option to set left- and right-indent with tabs and backspace is unchecked, pressing tab in the code will result in

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated February 4, 2024 Views 2,795 Applies to: