# Cursor Position / Insertion Point

Is there a way to access (or even set) the cursor position in a Notebook?

(By Cursor I refer to the keyboard input postion, or "Insertion Point". For the Mouse we have CurrentValue["MousePosition"] or just MousePosition[])

Note that calling external tools is only the seconds best option for me. See Programmatically move the cursor to a desired location on the screen (which is also about the mouse)

-
One thing that makes this question difficult to answer is lack of specification of the expected position datum -- should it be X number of Cells into the Notebook, or a certain number of characters into the expression returned by NotebookGet, or...? –  Mr.Wizard Oct 18 '12 at 9:37
You are right. I'm sure MMA has such a specification internally, but maybe it cannot be accessed!? So I was refering to that -unknown- internal spec. –  NoEscape Oct 18 '12 at 10:02
Fair enough. Let me ask the question in a different way: what would you do with this internal spec if you had it? There is apparently no way to feed it to SelectionMove. What kind of interaction are you envisioning? –  Mr.Wizard Oct 18 '12 at 10:04
The simplest application is just saving the insertion point and setting it back later! –  NoEscape Oct 18 '12 at 10:06
That's just the problem though; I don't know if any way to say "move cursor to point X" but only "move cursor X units of type Y in direction Z." Perhaps you could use some marker and then do a text search for that. I don't think there are many tools provided for this kind of thing; it's typically much easier to work with the Notebook expression than with the GUI Notebook itself. –  Mr.Wizard Oct 18 '12 at 10:17

Setting the position may be easier than retrieving it as there exists SelectionMove.
No record of the insertion point appears in the output of NotebookGet. At the moment the best I can think of is to use NotebookWrite to insert a unique token and then search the expression returned by NotebookGet for this token, but this changes the target Notebook.
Aha, from experimenting with SelectionMove I come to the conclusion that a "Selection" can also be empty and then just represents the Insertion point. This is not at all evident from the naming of that function! (this happens e.g. on SelectionMove[nb, Next, Character] –  NoEscape Oct 18 '12 at 10:11
With DeveloperCellInformation` you get the cursor position within the selected cell, and the selected cell serial number whatever that means –  Rojo Oct 18 '12 at 23:35