Show/Hide Toolbars

EmEditor Help

Navigation: EmEditor Help > Macro Reference > Tutorial

EmEditor Macro Reference: Insert Characters

Scroll Prev Top Next More
EmEditor Home - EmEditor Help - EmEditor Macro Reference - Tutorial

Insert Characters

To insert characters using a macro, use the Text Property. Modify our tutorial file as follows:


   document.selection.Text = "EmEditor supports macros.";


   document.selection.Text = "\tEmEditor is a text editor.";


   document.selection.Text = "EmEditor supports macros."


   document.selection.Text = Chr(9) & "EmEditor is a text editor."

The NewLine Method added in the second line inserts a newline character at the cursor position. The code in the third line inserts a tab character at the beginning of the string. A tab character is represented by "\t" in JavaScript, and Chr(9) in VBScript. You can also use the VBScript constant, vbTab, for a tab character.

The following tables list commonly used escape sequences in both scripting languages.







Horizontal Tab.



Newline character.



Form feed.



Carriage return.



Double quote.



Single quote.





The Latin-1 character with the encoding specified by the two hexadecimal digits.


The Unicode character with the encoding specified by the four hexadecimal digits.

g Reference: JScript Special Characters (Microsoft MSDN Library)



Carriage return.


Chr(13) & Chr(10)

Carriage return + newline character combination.



Form feed.



Newline character.


Chr(13) & Chr(10) or Chr(10)

Platform-specific newline character. Equivalent to vbCrLf in Windows.



Horizontal tab.



Vertical tab.

g Reference: VBScript String Constants (Microsoft MSDN Library)


Line-endings are terminated with a combination of a \r (CR) and a \n (LF). Use the CR and LF in distinct manners. For example, if you write:

document.selection.Text = "\n";

only carriage return (LF) is inserted, which is not a line-ending convention in Windows. When you press the RETURN key in EmEditor, EmEditor inserts whatever line-ending (CR only, LF only, or CR+LF) is used in that line. If you want the same behavior upon pressing the RETURN key, as in EmEditor, we recommend that you use the NewLine Method or the writeln Method.

Next Topic:

q Move Cursor

Copyright © 2003-2021 by Emurasoft, Inc.