Announcement

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

  • Shortcuts in the do-file editor

    Hi
    I'm very fond of shortcuts.
    So, it is very annoying to by accident invoke a copy of a marked line ie 2 exact same lines in row. Or invoke a double string, ie from "once " to "once once ".
    These shortcuts exists, because I do them by accident frequently.
    And this a nagging feeling that there is a lot of undocumented shortcuts, I do not know off.

    Do anyone have a list of do-file editor shortcuts?
    Kind regards

    nhb

  • #2
    Hi Niels,
    I was looking with interest what people will say here, but so far no reactions.
    I came across this from back in 2013:
    https://www.stata.com/statalist/arch.../msg00330.html

    Have tested these in Stata 16, here is my progress:

    Shortcuts in Stata main window
    ctrl-1; ctrl-Tab – Command line
    ctrl-3 – History
    ctrl-4 – Variables
    ctrl-5 – Properties
    ctrl-7 – Viewer
    ctrl-8 – Data Editor (Edit)
    ctrl-9 – Do File Editor
    ctrl-A – select all in Results
    ctrl-F – Find in results
    ctrl-S -- Save
    ctrl-shift-S -- Save As

    Shortcuts in Do File Editor
    ctrl-I -- Shift Right
    ctrl-shift-I -- Shift Left
    ctrl-N -- new file
    ctrl-O -- Open
    ctrl-S -- Save
    ctrl-shift-S -- Save As
    ctrl-H -- Replace
    ctrl-F -- Find
    ctrl-B -- Balance – selects all code between the current loop curly parentheses
    ctrl-D -- Do
    ctrl-shift-D -- Do to Bottom
    ctrl-R – Run
    ctrl-Tab – cycle through multiple do files/tabs in same editor window
    Shift + arrow keys and PgUp/PgDn selects text
    ctrl-Home -- go to top of buffer
    ctrl-End -- go to bottom of buffer

    not working in Stata 16

    ctrl-shift-Y -- Select Line
    ctrl-Y -- Delete Line
    ctrl-U -- Change Case (on selected text)
    F3 -- Find Next
    ctrl-L -- Go to Line
    ctrl-5 -- Match (*)

    not sure ?
    ctrl-PgUp -- cycle forward through multiple buffers
    ctrl-PgDn -- cycle backward through multiple buffers
    ctrl-Tab -- cycle backward through multiple buffers

    Comment


    • #3
      The do file editor uses Scintilla/SciTe editor components. Some of the SciTe keyboard shortcuts are available.

      http://www.scintilla.org/SciTEDoc.html

      http://the-automator.com/scite-edito...tcuts-hotkeys/

      Comment


      • #4
        Maria Boutchkova thank you for the list.
        Bjarte Aagnes thank you for the references to SciTe
        You both made my day
        Kind regards

        nhb

        Comment


        • #5
          Just discovered block editing which requires you to hold down ALT and SHIFT at the same time and mark a block using UP and DOWN arrows.
          An examples could that you have a number of lines like: label var "varlabel".
          Here, the word variable after label is forgotten.
          Place the cursor at the column where you want to add some text to more lines, eg just after the word label in first line, mark lines block with ALT+SHIFT and then write the word variable and a space.
          Then all lines becomes: label variable var "varlabel"
          Kind regards

          nhb

          Comment


          • #6
            BTW, I found somewhere that Cntl-Shift-E executes the current line. Very handy! (-- for commands that don't span multiple lines.)
            But I find that it works for me in stata 17 but not in stata 16 (although these are on different machines). If anyone knows why, I'd love to hear.

            Akiva

            Comment


            • #7
              Not to divert the conversation into a different topic, but in case someone knows, I could benefit from the following:

              I am commonly working on large projects, which involve multiple ado files for common tasks and a 'driver' do file that calls them in sequence. The ado files are not runnable by themselves. So to test the most recent changes I constantly have to go back and forth between the tabs of ado and do, which is a pain. What I'd like to have is a possibility to declare a 'main' or 'starting' file in a project that will be executed when Ctrl+D is pressed in any editing tab for the file that is part of the project (or even to re-declare it interactively, if no project is open). Ctrl+D is not critical, could be any other key combination.

              Alternatively, do-editor could be made smart enough to understand that *.ado files are not runnable, and when Ctrl+D is pressed, seek for a *.do file among the open tabs (I typically have only 1 such file, but this may vary among other users).

              In Microsoft's Visual Studio this is known as "startup project", described in simple terms e.g. here: http://www.blackwasp.co.uk/VSStartupProjects.aspx

              Thank you, Sergiy

              Comment


              • #8
                The closest way to emulate this is to put "static" code in your profile.do file, but this must be changed with each project and also only expected not to change when working on other files, as the profile.do is executed once at Stata startup. I think there may be some user contributed packages to this end that provide some convenience utilities, but I haven't used them.

                Comment


                • #9
                  Originally posted by Leonardo Guizzetti View Post
                  The closest way to emulate this is to put "static" code in your profile.do file, but this must be changed with each project and also only expected not to change when working on other files, as the profile.do is executed once at Stata startup. I think there may be some user contributed packages to this end that provide some convenience utilities, but I haven't used them.
                  Leonardo Guizzetti , could you please elaborate? I don't think that any code I put in any profile file will have any effect on the hotkeys in the do-editor. Specifically, if you are referring to the Function-keys macros, they are ineffective in the do-editor:

                  Code:
                  global F9 "do driver.do`=char(13)'"
                  Defines F9 key to run the driver program code from a Stata input line, but doesn't have any effect in the do-editor.

                  Thank you, Sergiy

                  Comment


                  • #10
                    Sorry Sergey, I have misunderstood your request. I was thinking of either having strangers code that could be loaded with Stata or else assigning a do file to be executed by pressing a function key. Neither of these relate to the do-file editor, though, which I now understand to be your main interest.

                    Comment

                    Working...
                    X