SelectionMove

SelectionMove[obj,dir,unit]

moves the current selection in an open notebook in the front end in the direction dir by the specified unit.

SelectionMove[obj,dir,unit,n]

repeats the move n times.

Details and Options

  • The first argument of SelectionMove can be a NotebookObject, CellObject, or BoxObject.
  • Possible direction specifications are:
  • Nextmake the selection be the next unit of the specified type
    Previousmake the selection be the previous unit of the specified type
    Aftermake the selection be just after the end of the present unit
    Beforemake the selection be just before the beginning of the present unit
    Allmake the selection be the whole of the present unit
  • Possible unit specifications are:
  • Characterindividual character
    Wordword or other token
    Expressioncomplete subexpression
    TextLineline of text
    GraphicsContentsthe contents of a graphics object
    Graphicscomplete graphics object
    CellContentsthe contents of a cell
    Cellcomplete cell
    CellGroupcell group
    GeneratedCellcell generated by the current evaluation
    Notebookcomplete notebook
  • Unless the option setting AutoScroll->False is given, the front end will scroll a notebook so that the result of SelectionMove is visible. »
  • The front end will also usually highlight the region corresponding to the result.
  • With direction specifications After and Before, SelectionMove will usually make the current selection be an insertion point between two units of the specified type. »
  • SelectionMove returns $Failed if it cannot move the selection in the way you request.
  • A GeneratedCell corresponds to an element of the output.

Examples

open allclose all

Basic Examples  (4)

Select the first cell after the initial selection position:

Select the third cell after the initial selection position:

Move selection to a cell:

Select the button that triggered the evaluation:

Scope  (1)

Create a notebook:

Move the selection to the first letter:

Move the selection to the CellGroup:

Move the selection to the graphics within the cell:

Move the selection to the end of the notebook:

Options  (1)

AutoScroll  (1)

Normally, any selection is visibly displayed in the notebook window regardless of its location:

With AutoScroll set to False, the selection is offscreen:

Properties & Relations  (1)

SelectionMove regards inline cells as equivalent to words:

To emulate keyboard cursor movement, use a front end token such as "MoveNext":

Possible Issues  (1)

SelectionMove can only select multiple cells as part of a CellGroup unit specification:

To select a series of individual cells, use a front end token such as "SelectNextLine":

Wolfram Research (1996), SelectionMove, Wolfram Language function, https://reference.wolfram.com/language/ref/SelectionMove.html (updated 2012).

Text

Wolfram Research (1996), SelectionMove, Wolfram Language function, https://reference.wolfram.com/language/ref/SelectionMove.html (updated 2012).

CMS

Wolfram Language. 1996. "SelectionMove." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/SelectionMove.html.

APA

Wolfram Language. (1996). SelectionMove. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SelectionMove.html

BibTeX

@misc{reference.wolfram_2024_selectionmove, author="Wolfram Research", title="{SelectionMove}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/SelectionMove.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_selectionmove, organization={Wolfram Research}, title={SelectionMove}, year={2012}, url={https://reference.wolfram.com/language/ref/SelectionMove.html}, note=[Accessed: 22-November-2024 ]}