Move Cursor (Tutorial)

To move the cursor, add the fourth line to our tutorial macro as follows:

[JavaScript]

document.selection.Text = "EmEditor supports macros.";
document.selection.NewLine();
document.selection.Text = "\tEmEditor is a text editor.";
document.selection.CharLeft( false, 12 );

[VBScript]

document.selection.Text = "EmEditor supports macros."
document.selection.NewLine
document.selection.Text = Chr(9) & "EmEditor is a text editor."
document.selection.CharLeft False, 12

Save the macro and run it in a new EmEditor window. Notice that the cursor is positioned at 12 characters left from the end of the line, or at the position where the first 't' character of "text editor" is. CharLeft Method moves the cursor the specified number of characters to the left. The first argument (false) of theCharLeft Method specifies whether the selection range is to be changed. That is, it specifies whether you want to use the SHIFT key when you use the LEFT ARROW key on your keyboard. The following methods are provided to manipulate cursor movements.

CharLeft

Move the cursor the specified number of characters to the left. Equivalent to the LEFT ARROW key.

CharRight

Move the cursor the specified number of characters to the right. Equivalent to the RIGHT ARROW key.

LineDown

Move the cursor the specified number of lines down. Equivalent to the DOWN ARROW key.

LineUp

Move the cursor the specified number of lines up. Equivalent to the UP ARROW key.

WordLeft

Move the cursor one word to the left. Equivalent to CTRL + LEFT ARROW.

WordRight

Move the cursor one word to the right. Equivalent to CTRL + RIGHT ARROW.

PageDown

Move the cursor down one tab. Equivalent to the PAGE DOWN key.

PageUp

Move the cursor up one page. Equivalent to the PAGE UP key.

StartOfLine

Move the cursor to the beginning of the line. Equivalent to the HOME key.

EndOfLine

Move the cursor to the end of the line. Equivalent to the END key.

StartOfDocument

Move the cursor to the start of a document. Equivalent to CTRL+ HOME.

EndOfDocument

Move the cursor to the end of a document. Equivalent to CTRL+ END.

GoToBrace

Move the cursor to the matching brace.

The following method moves the cursor to the specified line or digit position.

SetActivePoint

Set the cursor position.