Code alignment incorrect while copying from codeblock | Community
Skip to main content
Level 2
June 28, 2022
Solved

Code alignment incorrect while copying from codeblock

  • June 28, 2022
  • 1 reply
  • 1004 views

I have a document which is published as a PDF. There are multiple codeblocks containing code within the document. THe alignment of the code displayed in the PDF is correct.  When I copy the codeblock from the output and paste it in a txt file, I see that the alignment is not correct. The leading spaces are not shown, and so all the lines start at the same level. Is there any way to fix the alignment issue while copying the codeblock?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by manpreetk908

Hi @anish2 ,

 

Offering some generic solutions that you can try -

1) Try pasting using the option retaining source formatting.

2) You can select the code block or even the entire code in the file and apply the code indentation using any IDE such as eclipse and IntelliJ. You can also configure the indentation using IDE settings.

3) Use any online code beautifier for your file.

Regards,

Manpreet

1 reply

manpreetk908
manpreetk908Accepted solution
Level 4
June 30, 2022

Hi @anish2 ,

 

Offering some generic solutions that you can try -

1) Try pasting using the option retaining source formatting.

2) You can select the code block or even the entire code in the file and apply the code indentation using any IDE such as eclipse and IntelliJ. You can also configure the indentation using IDE settings.

3) Use any online code beautifier for your file.

Regards,

Manpreet