I have Action Keys I use all the time to delete all text forward / backward of cursor point - but I have yet to figure out or find a way to delete the current line. Really looking to do something like put the cursor anywhere in a line - and press a button to delete the full line. Anyone have this done that they could share? If not, will keep plugging away…
@sylumer@sylumer@khags@draft8
Hello,
thank you for the delete line actions
in terms of speeding up workflow and editing texts in drafts, delete line is a very useful action.
Please consider however that delete line is often used in the context of a large text being revised and the user quickly deleting one line after the other.
Both scripts above are not efficient in terms of workflow because following line deletion, there is a scroll action which puts the user somewhere random in the middle of the draft. The user has to return to where he was and resume reading or deleting.
Is there a way to:
1- delete line
2- put the cursor at the beginning of the next line (ready for another line deletion if necessary)
Even if the user does not want to delete the next line, but simply wants to continue reading, the scroll action breaks the workflow continuity.
thank you
Think about what you want to do. You want to delete some text and put the cursor at end of where the text was.
If you say want to delete the third line, afterwards you want to position your cursor at the start of the third line.
You know the starting position of the third line when you come to delete it.
You aren’t deleting anything before the third line.
The editor object allows you to set selected text, and this can be a position (from the start - i.e. where line 3 always starts unless you amend something on lines 1 or 2) and zero length.
Based on that, you should be able to position your cursor upon deletion.
Also you don’t need to tag people unless you want them to specifically respond to something. You certainly don’t need to tag me twice In addition, don’t forget that you can start a new topic and reference back to an old one. This particular topic is a year old now. Typically you would start a new topic saying I’ve found this (link), but want to change it to do this, is it possible?
thank you.
delete line: I will give it a try. In my defense, I would argue that the delete line action is not ‘functional’ in terms of workflow, as opposed to my personal preferences or a whim.
advice on posting: my apologies. I will heed your advice in the future.
But it did meet the OP’s requirement, and they clearly stated as such. Your requirement is an additional one or at widest scope, a variation. Presumably one that the OP did not require given their response
scrolling 'bug’
I traced back my steps, and found that the scrolling issue which causes the user to be catapulted somewhere into the middle of the draft after the line deletion happens on the iPad in landscape mode.
On the iPhone there is another issue: if I delete the line by putting the cursor at the start of the line, swiping left to the action list and tapping on the delete line action it works perfectly (although it is the paragraph, not the line which is deleted - see below). If however, I put the cursor at the start of the line, and tap on the delete line action on the sliding menu at the bottom of my draft, then the action is followed by a scroll which sends me somewhere in the draft and forces me to retrace my steps.
paragraph deletion
I don’t know how you define ‘line’, the following deletes the entire paragraph (multiple lines- the deletion stops where there is a new line) which is even better for my use, so thank you for the script. Fearing another reprimand and being banned from this forum,I tested it a gazillion times to make sure that the paragraph is indeed deleted.
let [st, len] = editor.getSelectedLineRange();
editor.setTextInRange(st, len, “”);
Once again, let me reiterate that I greatly appreciate your comments including your well worded and completely appropriate small reprimands.
Using this I carried out some quick tests. In each case the action removed the selected line, positioned the cursor at the starting position of the removed line. The text was always longer than a screen and I experienced no random or inadvertent scrolling on either device, or with the choice of action trigger.
In a Word Processor, a line is what reaches across a page. In a text editor a line is everything up to a line break/new line character. What you are probably doing is conflating line wrapping in a editor with lines in word processing.
I purposefully switched the text in the above screenshots to show line numbers to illustrate how Drafts is just wrapping lines, so the line appears to you a what would be termed a paragraph in a word processor.
You really shouldn’t fear any sort of reprimand. Only Greg has the power to block and remove users and you would be warned off bannable behaviour long before you would be excluded. If you are ever unsure of what is acceptable or not, simply refer to the details in the forum’s FAQ.