3

How is it possible to split the same text in two windows with TeXstudio, like it is done here : https://tex.stackexchange.com/a/364455/89734.

I like very much TeXstudio since a friend introduced me to it. This editor has really amazing features. But I miss this emacs feature: it enables e.g. to copy a part of a text and to paste it in another part (like a complicated formula) without having to scroll the text.

  • 1
    A user asks to to get an Emacs feature in another editor. If the other editor would have been vim, ok. But Texstudio? Just keep using Emacs. – Johannes_B Jul 11 '18 at 07:27
  • @Johannes_B That's really a useless comment. Because 1) TeXstudio has a lot of features that emacs does not have, 2) it is possible, see the picture. Unfortunately, the author of the post does not answer my question I posted 2 days ago. – Philippe Gaucher Jul 11 '18 at 07:41
  • 3
    I don't think TeXstudio can do this. See this open feature request. – Circumscribe Jul 11 '18 at 08:41
  • 1
    It's possible that the image you refer to is actually of two separate, but seemingly identical, files. – Torbjørn T. Jul 11 '18 at 08:49
  • @Circumscribe I'll take your comment as the answer. – Philippe Gaucher Jul 11 '18 at 09:27
  • @TorbjørnT. Yes indeed. I can already display two text files side-by-side; as a workaround, one possibility would be to write a script copying the file I am editing in another one which would be being edited at the same time, I'd just have to refresh the other window... I'll post something if I come up with something interesting. Because it's a really useful feature for large text file. – Philippe Gaucher Jul 11 '18 at 09:31
  • I've found a workaround actually ! I keep using TeXstudio and I open the text file also with gedit (I use Ubuntu). Every time the text file is changed, if I go to the gedit window, gedit warns me and asks me to reload the text. – Philippe Gaucher Jul 11 '18 at 09:37
  • You may wish to give due consideration to alzi's answer. The hard-link approach he describes is a great way to accomplish this, for any editor! – Steven B. Segletes May 01 '21 at 13:14

3 Answers3

4

I don't think TeXstudio can do this.

You can find an open feature request for this on the TeXstudio SourceForge page. In the discussion below this request one of the developers of TeXstudio indcates that this feature is unlikely to be implemented in the near future:

Tim Hoffmann — 2017-05-09

No changes. This is not possible with the current editor component and it doesn't look like there'll be an alternative. So as of now, there is no indication that this request can be fulfilled.

Circumscribe
  • 10,856
2

It is possible by adding a hard link in the file system and use the original file in the first view and the hardlinked file in the second view of the splitted editor window.

In detail...

To add a hardlink in NTFS filesystem you need to start cmd with administrator rights by pressing the WIN key, typing cmd, clicking "run as administrator". Lets assume your document is called document.tex. Then type:

mklink /H documentlink.tex document.tex

This will generate a hard link called documentlink.tex. This link behaves like a normal file.

Working with LUNIX the command:

ln document.tex documentlink.tex

should do the job.

So in the end you have two files document.tex and documentlink.tex pointing to the same data on hard-disk. This means when you edit (and save) one of the files the other one is also modified the same way.

Now you can load document.tex and documentlink.tex in the editor and move the documentlink.tex to the other view. Then change the data in document.tex. When you try to edit documentlink.tex you will be notified once that the file has changed.

It is possible to view different positions and copy and paste text between these files. When you save or compile one file, the other one is updated automatically.

I use this work around at the moment and it works very well for me, since my texfile has grown quite large.

Please use this settings in TexStudio:

Options menu
Configuration
Show Advanced Options
Adv. Editor
(uncheck) Safe writing of files
(check) Monitor open files for external changes
(check) Silently reload saved files on external changes

Safe writing to files will overwrite the hardlink since the programm saves to a temporary file and copies it to the file named in the editor. So it has to be deactivated.

When you work with Linux then load the original file first, then the hardlink. Move the hardlink to the second view and mark this tab as read only. Only edit and save the first tab. Now it works also under Linux :)


Here's a reference Steven pointed to: https://www.tenforums.com/tutorials/131182-create-soft-hard-symbolic-links-windows.html#option3

Because hard links are handled at the OS level, the technique works for any editor (confirmed [by Steven] for TeXworks).

alzi
  • 29
  • 4
    Welcome to TeX.SE! Can you add an screenshot and explain a little bit better what one has to do to get the wished result ... – Mensch Apr 28 '21 at 10:12
  • That does not work for me. By hard link, you mean ln file1 file2 ? – Philippe Gaucher Apr 28 '21 at 13:12
  • Works for me in a Windows system. This is great! And because it is handled at the OS level, the technique works for any editor. Thank you! Here is a Win reference: https://www.tenforums.com/tutorials/131182-create-soft-hard-symbolic-links-windows.html#option3. Perhaps you might want to edit your answer and list this (or other) links. – Steven B. Segletes May 01 '21 at 13:09
  • Also, I am able to do this without running as administrator. Can you think of any reason why doing so would be a problem? – Steven B. Segletes May 01 '21 at 13:18
  • I am happy for Windows users. Unfortunately, this workaround does not work for linux. – Philippe Gaucher May 01 '21 at 14:41
  • @PhilippeGaucher While I do not use Linux myself, I did find this webpage that talks of hard links: https://linuxhandbook.com/hard-link/ – Steven B. Segletes May 27 '21 at 00:39
1

As an alternative, you can do it by opening a second window (instance) of TexStudio with the same .tex file. To do this, you need to follow this post.

  • Yes it works ! Under Ubuntu, change in /usr/share/applications/texstudio.desktop the line Exec=texstudio %F to Exec=texstudio --start-always %F. I mark your post as the answer. – Philippe Gaucher Feb 20 '22 at 08:41