Menu

#548 Let [Tab] conditionally indent or go to next placeholder

open
nobody
None
5*
2017-11-12
2013-09-17
doncherry
No

Currently, I can assign the Tab keyt either to “Indent Selection” or to “Next Placeholder”. I would like to configure the following behavior:

if cursor_in_placeholder:
    put_cursor_in next_placeholder
else:
    indent

And the reverse for Shift+Tab, of course.

Related

Feature Requests: #1323

Discussion

  • Tim Hoffmann

    Tim Hoffmann - 2013-09-17

    This can already be achieved by a proper javascript user macro.

    You may create a script for the above task and assign <tab> as a shortcut to it in the options.</tab>

    See the section on user macros in the manual and example scripts in the wiki.

    You'll want the following undocument function

    <s>editor.currentPlaceHolder() // returns -1 if it is not in a placeholder</s>
    

    Edit: Sorry, it's more complex than I thought. First, editor.currentPlaceHolder() works differently than I thought. You can't use it here. Second, scripts currently cannot be used for moving the cursor around.

     

    Last edit: Tim Hoffmann 2014-05-11
  • danieldo

    danieldo - 2014-05-10

    Wow, really great hint, I was looking for this feature for quite some tim. Thanks!

    I tried to implement it with the following script, but I can't get it to work -- the script always indents the current line, even if the cursor is inside a placeholder. Any idea what I did wrong?

    %SCRIPT
    if(editor.currentPlaceHolder() == -1){
        editor.indentSelection();
    } else {
        editor.nextPlaceHolder();
    }
    
     
    • Tim Hoffmann

      Tim Hoffmann - 2014-05-11

      You are right. There is currently no way to achive this functionality. See my comment above.

       
  • Morten Nissov

    Morten Nissov - 2017-11-12

    Is this possible yet?

     
  • Tim Hoffmann

    Tim Hoffmann - 2017-11-12

    No, nothing changed here.

     
    • Morten Nissov

      Morten Nissov - 2017-11-12

      Are there any plans to add this funtionality?

       
      • Tim Hoffmann

        Tim Hoffmann - 2017-11-12

        While this functionality is reasonable (like many others), this is not a priority. So no plan. You can upvote the ticket. It increases the likelyhood of implementation if there is much interest.

         

Anonymous
Anonymous

Add attachments
Cancel





Auth0 Logo