Menu

#953 Disable indentation when pasting

None
open
nobody
None
5*
2017-10-06
2014-03-31
No

I still get the bug someone before me described in issue #151: When I copy a bit of indented code and paste it exactly afterwards, it is indented too much.

I would like to completely disable automatic indentation during "pasting" (CTRL+V) of content, but of course keep the very useful normal indentation mode ("same as line above") for all other things than pasting content.

So for example: (read "-" as the tab or indentation character)

I have this content:
- \begin{itemize}
- - \item Myitem1
- - \item Myitem2
- - \item Myitem3
- \end{itemize}

If I copy and paste that directly below, it becomes this:
-\begin{itemize}
- - - \item Myitem1
- - - \item Myitem2
- - - \item Myitem3
- - \end{itemize}

This is rather annoying when using a lot of indented code.

It would be really awesome if this could be fixed. Thanks for all your work!

Discussion

  • Tim Hoffmann

    Tim Hoffmann - 2014-04-01

    Works here with version 2.7.0. Which version are you using?

     
  • Benito van der Zander

    And which indentation mode is set in the editor options?

     
  • Ingmar Schlecht

    Ingmar Schlecht - 2014-04-05

    I use version 2.7.0 as well, and I do get the mentioned bug. I have attached some screenshots that demonstrate the issue.

     
  • Ingmar Schlecht

    Ingmar Schlecht - 2014-04-05

    screenshot 2

     
  • Ingmar Schlecht

    Ingmar Schlecht - 2014-04-05

    Screenshot 3

     
  • Ingmar Schlecht

    Ingmar Schlecht - 2014-04-05

    Screenshot 4

     
  • Ingmar Schlecht

    Ingmar Schlecht - 2014-04-05

    Note: Screenshot 3 just visualizes where the cursor was placed before pressing CTRL+V for inserting the content. (Of course I removed the X before pasting.)

    The point now is: I basically want the editor to not do anything about indentation when pasting. Because I usually know very well what code or indentation I have in the clipboard and I would really like it to come out of the clipboard exactly like that. So a mode to disable indentation during pasting would be really excellent.

    But of course I would like to keep the normal indentation help, i.e. that a new line is always indented at the same level than the line above during normal editing.

    Thanks a lot for looking into the issue. Apart from this little glitch I really love TeXStudio.

     
  • Tim Hoffmann

    Tim Hoffmann - 2014-04-05

    If indentation handling would be completely deactivated during pasting, your example would give the result shown in the screenshot. The first line will have double indentation, one because your cursor (at x) is already indented and one because the pasted code is indented. All further lines are pasted directly and will have only the single indentation from the original part. Is that really what you want?

     
  • Ingmar Schlecht

    Ingmar Schlecht - 2014-04-14

    First of all, sorry for the late response. I really would like to get this fixed (or an option implemented), so I try to be as helpful in explaining the issue as possible.

    Regarding your point: Of course, if I did it exactly like that it would still not be quite perfect, but a LOT better, because not everything is accidentally indentend too much but just the first line.

    Actually, my example was a bit imprecise. For copying, I should of only marked the text beginning from the \begin and not from the start of the line. That is actually what I normally do by habit in all other editors.

    What I also very often do in other editors for duplicating a bit of code is copying by marking full lines from the start and then (keeping things selected, i.e. highlighted in blue) pressing CTRL+V twice. That also does not work in TexStudio.

    My main point actually is that this works so differently to all other editors and I am always confused when I work with TexStudio in terms of indentation. I understand that if I always go to the beginning of the line during pasting it is OK. But in general I think disabling this indentation completely during pasting would be better for most users. But if just an option would be implemented, that would be OK for me as well.

    Thanks a lot again for your work!

     
  • Tim Hoffmann

    Tim Hoffmann - 2014-04-14

    Indeed, there are some issues with the indentation and pasting.

    Regarding your point: Of course, if I did it exactly like that it would still not be quite perfect, but a LOT better, because not everything is accidentally indentend too much but just the first line.

    It's not yet clear to me if "Disable indentation when pasting" is an option by its own right, of if you are just requesting this as a workaround because the smarter indentation modes don't work correctly.

    In the latter case, I'd rather fix the original indentation algorithm than add a "not quite perfect" workaround.

     
  • Jan  Sundermeyer

    Jan Sundermeyer - 2014-05-16

    is this fixed by now ?

     
  • Tim Hoffmann

    Tim Hoffmann - 2014-05-17

    No. Still not sure if the requested option is necessary or if we should fix the behavior of the smart indent instead.

     
  • Tim Hoffmann

    Tim Hoffmann - 2014-11-18

    fixed: 4796 (a4bddd059f94)

     
  • Tim Hoffmann

    Tim Hoffmann - 2014-11-18
    • status: open --> fixed
    • Group: -->
     
  • Tricolore

    Tricolore - 2017-08-26

    When will this fix be available on Windows?

     
  • Tim Hoffmann

    Tim Hoffmann - 2017-09-30
    • status: fixed --> open
     
  • Tim Hoffmann

    Tim Hoffmann - 2017-09-30

    reopened due to regression: not exactly as before.

    Minimal example:

        \begin{itemize}
            \item Myitem1
            \item Myitem2
            \item Myitem3
        \end{itemize}
    
    1. Select
    2. Copy
    3. Paste
    4. Paste again

    Result:

        \begin{itemize}
            \item Myitem1
            \item Myitem2
            \item Myitem3
        \end{itemize}
        \begin{itemize}
        \item Myitem1
        \item Myitem2
        \item Myitem3
    \end{itemize}
    

    This does only occur, when indentation mode is set to Indent / Unindent automatically.

     

Log in to post a comment.