To delete characters, add the fifth line to our tutorial macro:
document.selection.Text = "EmEditor supports macros.";
document.selection.NewLine();
document.selection.Text = "\tEmEditor is a text editor.";
document.selection.CharLeft( false, 12 );
document.selection.DeleteLeft( 15 );
document.selection.Text = "EmEditor supports macros."
document.selection.NewLine
document.selection.Text = Chr(9) & "EmEditor is a text editor."
document.selection.CharLeft False, 12
document.selection.DeleteLeft 15
Save the above macro and run it in a new EmEditor window. Notice that the 15 characters from the left side of the text editor (that is, "(tab)EmEditor is a ") are deleted. The text should now read as follows:
"EmEditor supports macros."
"text editor."
DeleteLeft Method deletes the specified number of characters from the left side of a string. If text is being selected, the selected text is deleted; pressing the Backspace key on your keyboard gives you the same effect.
Similarly, the following methods are provided to delete characters:
| Delete | Delete the selected text. If no text is selected, it deletes the specified number of characters from the right side of a string. Equivalent to the Delete key. |
| DeleteLeft | Delete the selected text. If no text is selected, it deletes the specified number of characters from the left side of a string. Equivalent to the Backspace key. |
You can delete words or lines by combining methods:
| Delete a word. | document.selection.SelectWord(); document.selection.Delete(); |
| Delete a word left of the cursor. | document.selection.WordLeft(true); document.selection.Delete(); |
| Delete a word right of the cursor. | document.selection.WordRight(true); document.selection.Delete(); |
| Delete a line. | document.selection.SelectLine(); document.selection.Delete(); |
| Delete a line left. | document.selection.StartOfLine(true, eeLineLogical); document.selection.Delete(); |
| Delete a line right. | document.selection.EndOfLine(true, eeLineLogical); document.selection.Delete(); |
| Delete an entire document. | document.selection.SelectAll(); document.selection.Delete(); |
| Delete a word. | document.selection.SelectWord document.selection.Delete |
| Delete a word left of the cursor. | document.selection.WordLeft True document.selection.Delete |
| Delete a word right of the cursor. | document.selection.WordRight True document.selection.Delete |
| Delete a line. | document.selection.SelectLine document.selection.Delete |
| Delete a line left. | document.selection.StartOfLine True, eeLineLogical document.selection.Delete |
| Delete a line right. | document.selection.EndOfLine True, eeLineLogical document.selection.Delete |
| Delete an entire document. | document.selection.SelectAll document.selection.Delete |
Send feedback on this topic to Emurasoft