Forum > Editor
Block/Line Indent\Unindent Hotkey with persistent selection
Tony Stone:
What is the expected behavior when using the shortcuts to indent/un-indent a line (CTRL+I / U) when there is a persistent selection. I just discovered the persistent block today and it looks very handy however it seems there may, or may not be a bug in it. When I have a block persistently selected and i move the caret to another line, what should be indented or un-indented when hotkeys are pressed? It seems it saw at different times the persistent selection indented and other times the line with the caret indented. So I am not sure how that would work in other editors but something seems off to me. I am also wondering if it would make more sense to have a persistent block by using a key modifier while selecting text rather than having a option in the Options > General > Persistent Block section? It seems like an option you would not often want on but when you want to use it you want it quickly enabled. Just some thoughts and curious if I should consider a bug report.
Update:
I may have posted about this to soon. I don't think I was accurate when I saw the line with a caret indented while there was a persistent selection. Just not sure now. I am experimenting with it now and I think it is probably working as designed. I am still curious though if there is a way I can use a key modifier while selecting text to force it to be a persistent selection? Going through options now trying to figure that one out still.
Blaazen:
Selection disappears when you move caret without modifier. When you have selection you can of course use CTRL/SHIFT+Arrow keys to scroll / edit selection.
But there's one more feature. Source Editor supports multiple carets and a new caret can be added by Ctrl+Click*. In that case you can have persistant selection and more carets.
*) I'm not sure if CTRL+Click is default or if I configured it.
Martin_fr:
@Baazen: persistent selection => this is an option, allowing the selection to be independent of the caret.
@Tony:
There probably isn't any expected behaviour. I don't think (meaning I am pretty sure) that any thought was ever spend on how it should behave. The indent functionality was simple implemented and tested with normal selection. And the behaviour for persistent is the same, never mind if sensible.
This is probably true for a lot of functions.
I don't use persistent block myself, so I am happy to receive feedback on it.
If I was asked, I would say that maybe it should either:
- act only on the selection if the caret is in the selection (or at one of the bounds of it)
- act only on the selection if the caret is on any line that is (at least partly) covered by the selection (even if the caret is not in the selection).
The excludes lines, where the selection bound is at the start-of-line (the previous line is selected including the linefeed // that means the selection bound is at a line, which has no selection highlight)
EDIT:
Needs also separate testing for block indent with
- tab key
- ctrl-i
Tony Stone:
I have researched it a little more last night. It is not a new feature it doesn't seem. Probably does need a little refinement from what I was able to do with it. Like I said it would be very handy if it worked the way I was expecting which would be like the following:
Only set a persistent selection with a key modifier, while using the mouse or SHIFT+Arraow Keys(that could be cumbersome and too many keys)
And I would expect a CTRL-C copy to copy the selected text and CTRL-V paste at the carret. It seemed to me that more than once a paste replaced the selection which didnt seem right.
Either way for the most part I am not so sure this is a feature very many people would use but last night while trying to clean up some of my code it seemed like it was gonna be an awesome tool to use while moving text etc. Just didn't seem to work out quite right. I will have to tinker with it some more over the weekend... chances are I am probably not using it right. I also found some references to using CTRL-K and CTRL-B to persistently select blocks but again... i think I was possibly doing it wrong. I will see what better feedback I can give this weekend on it's use. I am also wondering if having a cloned code editor played a role in some of the incosistent behavior. I will experiment with out a cloned editor as well.
Martin_fr:
--- Quote from: Tony Stone on February 10, 2023, 02:15:29 pm ---Only set a persistent selection with a key modifier, while using the mouse or SHIFT+Arraow Keys(that could be cumbersome and too many keys)
--- End quote ---
That would be a new feature.
Currently "persistent selection" is an option that is either on or off (and also has no key to toggle it / which would be enough to kind of make your request work)
You may have seen "sticky" selection. But that just means you don't have to hold shift to expand the selection ((should) work independent of persistent).
That allows you to set a bookmark, search for some text, start sticky selecting at that "some text", go to the bookmark, and finish selecting. (great in editor-macros)
--- Quote ---And I would expect a CTRL-C copy to copy the selected text and CTRL-V paste at the carret. It seemed to me that more than once a paste replaced the selection which didnt seem right.
--- End quote ---
That should be the case for any mode, except
When you have none-persistent selection, then the caret must be at the selection. In this case the option "overwrite selection" will decide if the pasted text replaces the existing selection or not.
That option also affects, what happens to a non-persistent selection when you type new text.
--- Quote ---Either way for the most part I am not so sure this is a feature very many people would use but last night while trying to clean up some of my code it seemed like it was gonna be an awesome tool to use while moving text etc. Just didn't seem to work out quite right. I will have to tinker with it some more over the weekend... chances are I am probably not using it right. I also found some references to using CTRL-K and CTRL-B to persistently select blocks but again... i think I was possibly doing it wrong. I will see what better feedback I can give this weekend on it's use.
--- End quote ---
There is ctrl-k, b and ctrl-k, k to set begin/end of the selection. IIRC only works when the option "persistent selection" is on.
It does not force a persistent selection, when that option is off (though that may be an interesting idea)
ctrl-k, b to move the persistent block...
There are also thinks like (independent of persistent / not for column selection)
- move line(s) up/down
- move selection up/down (and iirc left/right)
- copy, but append to existing clipboard
- copy current line / copy line, append
--- Quote --- I am also wondering if having a cloned code editor played a role in some of the incosistent behavior. I will experiment with out a cloned editor as well.
--- End quote ---
Should not matter at all.
None of those commands have any reference to the code dealing with cloned-edits.
Navigation
[0] Message Index
[#] Next page