Post by Stefan on Feb 11, 2021 10:16:29 GMT -5
I just came across these recently. I think the word 'nifty' describes the effect.
I tend to place comments in a column at the right end of source code lines and they prevent shifting the comments about when the code part changes in length.
I've mapped the functions as CTRL+Insert and CTRL+Delete. (I'm still training my brain to press CTRL when appropriate, but I'm getting there.)
So far so good, but while (DataInsert) is intuitively useful, I find (DataDelete) less so.
I think the difference stems from the <Insert> and <Delete> keys' function.
The <Insert> key sets a 'typing mode' but the effect is achieved by normal typing.
In contrast, the <Delete> key acts on the data itself.
Thus (DataDelete) effectively only removes non-blank characters, or more precisely, does not remove multiple-blank characters.
This renders it useless in the common use case of 'out-denting' a code line. For example.
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
000001 This is some code statement /* and this is a comment */
000002 This is code statement /* and this is a comment */
000003 This is code statement /* and this is a comment */
Place the cursor under the 's' of 'some' on line 1, press CTRL-DELETE 4 times and you get line 2.
But place the cursor anywhere in columns 1 to 4 in line 1 and CTRL-DELETE does nothing because there are two (or more) blanks between the cursor position and the next non-blank character.
So (DataDelete) can only be used effectively if you wish to remove parts of the code statement. It cannot be used to 'outdent' the code statement, leaving the comment in place.
My suggestion:
(DataDelete) should treat multiple 'leading' blanks between the cursor position and the next non-blank character as a if they were 'non-blank' chars.
Alternatively, but less intuitive, treat multiple 'leading' blanks as a single blank.
In that case, (DataDelete) would achieve the result shown on line 3 when CTRL-DELETE is pressed with the cursor in column 2 of line 1.
I appreciate that seems to fly in the face of its name (DataDelete).
But it would make (DataDelete) the logical opposite of (DataInsert), which already works to 'indent' the code statement without moving the comments.
(As for the name, dare I say, technically (DataInsert) doesn't insert any data at all, ever.)