Author Topic: Extending selections  (Read 968 times)

jporkkahtc

  • Senior Community Member
  • Posts: 1506
  • Hero Points: 129
  • Text
Extending selections
« on: March 09, 2017, 07:26:49 pm »
Is there a way to select text from the current position to whereever the cursor ends up next?
(Or, to select from where the cursor is now to where it was last?)

For example, there is select-matching-brace as a special purpose match from here to the matching brace.

But there are lots of other ways of moving the cursor, with search, goto line, the arrow keys, etc.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4180
  • Hero Points: 300
Re: Extending selections
« Reply #1 on: March 10, 2017, 03:59:49 am »
Try using the select-char command. This creates a sticky selection which will extend as the cursor moves. To get rid of the sticky selection, use the deselect command.

jporkkahtc

  • Senior Community Member
  • Posts: 1506
  • Hero Points: 129
  • Text
Re: Extending selections
« Reply #2 on: March 15, 2017, 05:50:48 pm »
It does work with simple keyboard navigation (arrow, home, end, pageup/down, scroll_up/down, etc).
It does not work with shift-arrows - well sort-of, if you select_char, then use shift-arrows the selection mode switches to the non-sticky variety.
It doesn't work with some other things I'd like either.
select_char
arrow around a bit to select some text
then use the "defs" tool to navigate.

The selection isn't cleared, but it doesn't extend anymore

It doesn't work with searching, quick_search, find_next, find_prev, etc.


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4180
  • Hero Points: 300
Re: Extending selections
« Reply #3 on: March 15, 2017, 06:25:49 pm »
Some commands will "lock" the selection so it can't be extended. Once the selection is "locked" there is no explicit "unlock" command. You must create a new selection. For example, if you do a select-char, move the cursor, then do another select-char, the selection will be locked. In other cases, a command may need to lock the selection in order to do something useful (like a search within a selection--kinda useless if it doesn't). In other cases, the command should not have locked the selection. We try not to do this but it happens. find-next and find-prev allowed me to extend the selection but that's because I have def_leave_selected off. Mini-find doesn't support it unless it's quite a sunny day (3 settings need to be changed from the default). Quick search is disabled when there is a selection.

This style of selection was really designed for emulations. It was never intended to just make sure every command can extend the selection.

As a work around, you can set a bookmark at the start where you want the selection, then search or do whatever you want to find a location, then use select-char at the end and go to the start bookmark.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2364
  • Hero Points: 319
Re: Extending selections
« Reply #4 on: March 24, 2017, 03:31:43 pm »
A slightly simpler version of Clark's bookmark trick is to push a bookmark, then do your cursor movement, whatever it is, then select-char, then pop-bookmark.  That way you don't have anything to clean up afterwards.