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

open
nobody
None
5*
2014-08-28
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</tab>, of course.

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.

    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.

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks