Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Convert tabs to spaces in results window

    Hello everyone, I have the habit of inserting tabs in my code to facilitate readability. Apparently, I am not the only one (https://medium.com/the-stata-guide/t...e-52418ce35006). My text editor converts a tab to four spaces. However, it seems that Stata's Results window converts a tab to eight spaces. This is purely cosmetic, but is there a way to make Stata's Results window (not the Do-file Editor) convert a tab to four spaces? By the way, I know that I can convert a tab to eight spaces in my text editor, but I like four spaces. Any thoughts are appreciated.

    In my text editor:

    Click image for larger version

Name:	Screenshot 2021-11-10 173113.jpg
Views:	1
Size:	20.0 KB
ID:	1635935



    In Stata:
    Click image for larger version

Name:	Screenshot 2021-11-10 173150.jpg
Views:	1
Size:	25.3 KB
ID:	1635936


    Code:
    clear all
    sysuse auto
    
    gen sample_indicator = cond(                             ///
        20         <= mpg             & mpg             >= 30     &     ///
        2         <= rep78         & rep78         >= 4     &     ///
        10         <= trunk         & trunk         >= 20     &     ///
        2000     <= weight         & weight         >= 4000 &     ///
        100     <= displacement & displacement     >= 400         ///
    , 1, 0)

  • #2
    Originally posted by Rafael Copat View Post
    ... it seems that Stata's Results window converts a tab to eight spaces. This is purely cosmetic, but is there a way to make Stata's Results window (not the Do-file Editor) convert a tab to four spaces? By the way, I know that I can convert a tab to eight spaces in my text editor, but I like four spaces. Any thoughts are appreciated.
    1. No. I don't think there is any setting that would make Stata interpret a tab in output as 4 instead of 8 characters (which is the default).
    2. If you like 4 spaces in the editor it is fine. But use the genuine 4 space characters (ascii code 32) instead of a single tab character (ascii code 09).
    3. If you already have a large file, you can make Stata convert it for you. There is an appropriate menu item in EDIT-->ADVANCED-->CONVERT TABS TO SPACES. It will use the parameter you set in the dialog, and yes, it can be 4.

    In fact, why are you still using a different editor? and which one?
    Stata's built-in editor has improved quite a bit in recent versions.

    Comment


    • #3
      If I use a third party editor, the only reason is that Windows 7 combine Stata main windows and its dofile editor into one button in Taskbar, thus makes it inconvenient for me to switch between main windows and dofile editor. And if I choose 'Never Combine', other programs will make the Taskbar fill up.
      P.S.And this is why I add a MATLAB style or RStudio style GUI/IDE in Stata Wishlist.
      Last edited by Chen Samulsion; 10 Nov 2021, 18:48. Reason: GUI

      Comment


      • #4
        Sergiy Radyakin, thank you for your reply. Your suggestion of converting tabs to spaces in the text editor is a nice workaround.

        I use Sublime Text with StataEditor, a package written by Mattias Nordin. It is true that Stata's do file editor has improved in recent years. However, Sublime Text is a very powerful and light editor. It allows for multiple cursors, search across multiple files, customize key bindings, etc. In addition, it has a package that simulates Vim, allowing commands that do not require you to use the mouse or move your hands to reach the arrow keys. Finally, it is very convenient to use the same text editor for Stata, LaTeX, Markdown, or any other language.

        Thank you again,

        Rafael

        Comment


        • #5
          Rafael Copat, thank you for sharing. I use StataEditor in Sublime Text environment too. However, what annoy me is that when I quit Sublime Text, the Stata will also be shut down, i.e.
          Stata is about to close. Restart Sublime Text to restore the session.
          If we can prohibit Sublime Text to do this (when we shut down Stata's built-in dofile editor, Stata will not quit!), it will be more convenient.

          Comment


          • #6
            Hi Chen Samulsion, I agree that StataEditor is not perfect. At this point, I got used to always exit Stata before closing the do file in Sublime Text. Still, functionalities like multiple selection, snippets, auto-completion of functions, on the top of what I said before make Sublime Text worthwhile in my opinion.

            Comment

            Working...
            X