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!
Works here with version 2.7.0. Which version are you using?
And which indentation mode is set in the editor options?
I use version 2.7.0 as well, and I do get the mentioned bug. I have attached some screenshots that demonstrate the issue.
screenshot 2
Screenshot 3
Screenshot 4
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.
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?
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!
Indeed, there are some issues with the indentation and pasting.
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.
is this fixed by now ?
No. Still not sure if the requested option is necessary or if we should fix the behavior of the smart indent instead.
fixed: 4796 (a4bddd059f94)
When will this fix be available on Windows?
reopened due to regression: not exactly as before.
Minimal example:
Result:
This does only occur, when indentation mode is set to Indent / Unindent automatically.