16

In TeXstudio, if I paste lines of text that contain leading spaces, they are altered automatically by the editor producing an undesirable layout.

MWE: Copy the following snippet and paste it in the editor.

\begin{verbatim}
    1
  -----
  s + 1
\end{verbatim}

This is how it looks after pasting:

\begin{verbatim}
1
-----
s + 1
\end{verbatim}
  • Why is this happening?
  • How can I keep the indentation of the pasted text intact?
18

TeXstudio offers three indentation modes:

  • Ignore Indentation: turns auto-indentation off.
  • Keep Indentation: copies the indentation from the previous line.
  • Indent and Unindent Automatically: re-indents text automatically to match the context.

From the TeXstudio User Manual:

The selection box "Indentation mode" lets you select, wether indented lines are followed by lines of the same indentation after pressing Enter or letting TeXstudio do automatic indentation.

"Indent and Unindent Automatically" mode is enabled by default. Since you want to preserve the indentation of the text you need to change this setting to "Ignore Indentation".

Go to Options > Configure TeXstudio > Editor

TeXstudio indentation mode

Other sources:

  • 12
    It's quite unfortunate there is no way to disable auto-indentation when pasting but keep automatic indentation when typing in the editor. – eregon May 24 '18 at 17:05
  • 1
    I think the 'Keep Indentation' option is essentially this @eregon – Toby Hawkins Mar 2 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.