Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17445
    sirfoobar
    Participant

    Hello,
    Thank you again for a wonderful product.

    I use “Insert spaces for tabs.” However, it would be very useful for Backspace to eat spaces back to the tab stop. This would allow Backspace to de-indent the line.

    Here is how the behavior should work in my opinion:

    [Each dot is a space. | is the cursor. The left side is before backspace is pressed. The right side is after backspace is pressed. Indent columns is 4 in this example.]

    ....|             ->   |   
    .....|            ->   ....| 
    ......|           ->   ....|
    ........|         ->   ....|
    .........|        ->   ........| 
    ........abcd...|  ->   ........abcd..|    //backspace should not eat multiple spaces after non-whitespace

    I have created a macro to perform this behavior, and it is below, but I would very much like to see this functionality in EmEditor itself. The problem with the macro is that setting “indentsize = document.Config.Indent.IndentColumns;” creates too much lag while EmEditor accesses the config files. It makes it impossible to hold down backspace smoothly. Therefore in the macro I have to hard-code indentsize. It would be better if this were a built-in behavior so that a macro was unnecessary.

    However, I very much appreciate that the macro engine is powerful enough that I can code this behavior myself.

    All the best, Garth

    smart_delete_left.jsee

    if (document.selection.Text.length > 0) {
    	document.selection.Delete();
    } else {
    	indentsize = 4; //document.Config.Indent.IndentColumns;
    	xpos = document.selection.GetActivePointX( eePosLogical );
    	ypos = document.selection.GetActivePointY( eePosLogical );
    	document.selection.SetActivePoint( eePosLogical, 1, ypos, true );
    	fromstart = document.selection.Text;
    	if( xpos != 1 && (xpos - 1) % indentsize == 0 && fromstart == Array( fromstart.length + 1 ).join(" ") ) {
    		document.selection.UnIndent();
    		document.selection.SetActivePoint( eePosLogical, xpos - indentsize, ypos, false );
    	} else {
    		document.selection.SetActivePoint( eePosLogical, xpos, ypos, false );
    		document.selection.DeleteLeft();
    	}	
    }
    #17446
    sirfoobar
    Participant

    In case it wasn’t clear, I think this would be useful as an option, not necessarily the default behavior. Thank you.

    #17470
    Meir
    Participant

    Dear Sirfoobar,

    How would you know which spaces where inserted with the TAB key and which with the space bar. The whole idea behind spaces rather than TABs is to make the file look the same on different boxes, with different text editors having different settings.

    And why can’t you select the line/lines and type SHFT-TAB. That un-indents all lines selected to the tab stops even if the number of spaces is not an integer multiple of the tab spaces.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.