- Apr 26, 2021 A textmacro is a shortcut for a sequence of keystrokes. A macro can be simple—it can type a word or phrase you use often—or it can be complex, such as a formatted address. A macro code is the name of the text macro you create.
- AutoHotkey is a free, open-source scripting language for Windows that allows users to easily create small to complex scripts for all kinds of tasks such as: form fillers, auto-clicking, macros, etc.
- If you want to create a text macro from existing text,select the text in the document.
- Choose New Macro from the Text Macros panel menu, orclick the New Macro button inthe Text Macros panel.
- Enter a macro code in the Macro Code text box. Note thatmacro codes are case-sensitive.
- For Macro Text, type the text string that you want enteredwhen you activate the text macro.
- To include text attributes from the existing text wheninserting or swapping macro text, select Remember Text Attributes.
By default, inserted or swapped macro text uses the styleattributes of the destination paragraph.
- To assign a keyboard shortcut for activating the macro,place the cursor in the Macro Key Shortcut text box, andpress the keys you want to use for the shortcut.
Shortcuts are especially useful if you turn off AutomaticallySwap Macro Text in the Text Macros panel.
If the keyboardshortcut you want to assign to the macro is already assigned to anotherfunction, the alert symbol appears at the bottom of the dialog boxwith the message “Currently Assigned To: [function].”If you choose to assign the keyboard shortcut to the macro, theprevious keyboard shortcut function is overridden.
Wrap Text to a Cell using VBA. Use the following steps to apply Wrap Text using a VBA Code. Define the cell where you want to apply the wrap text using the range property. Type a dot to see the list of the properties and methods for that cell. Select the “WrapText” property from the list. Enter the equals sign “=” and the type TRUE to. Text is a worksheet function in excel but it can also be used in VBA while using the range property with it, the function for this function is similar to the worksheet function and it takes the same number of arguments which are the values which needs to be converted and a specified number format. Excel VBA Text Function. Here is a list of the best free Auto Typer Software for Windows.These let you type the text automatically. You can choose to save the Macros and then choose different properties to auto type the text, like: speed of typing, number of times the text is to be repeated, typing case, typing format, and many more such options.
Language | ||||
Standard Library Headers | ||||
Freestanding and hosted implementations | ||||
Named requirements | ||||
Language support library | ||||
Concepts library(C++20) | ||||
Diagnostics library | ||||
Utilities library | ||||
Strings library | ||||
Containers library | ||||
Iterators library | ||||
Ranges library(C++20) | ||||
Algorithms library | ||||
Numerics library | ||||
Localizations library | ||||
Input/output library | ||||
Filesystem library(C++17) | ||||
Regular expressions library(C++11) | ||||
Atomic operations library(C++11) | ||||
Thread support library(C++11) | ||||
Technical Specifications |
General topics | ||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||
Flow control | ||||||||||||||||||||||||||||||||||||||||||||||
Conditional execution statements | ||||||||||||||||||||||||||||||||||||||||||||||
Iteration statements (loops) | ||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||
Jump statements | ||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||
Functions | ||||||||||||||||||||||||||||||||||||||||||||||
Function declaration | ||||||||||||||||||||||||||||||||||||||||||||||
Lambda function declaration | ||||||||||||||||||||||||||||||||||||||||||||||
inline specifier | ||||||||||||||||||||||||||||||||||||||||||||||
Dynamic exception specifications(until C++20) | ||||||||||||||||||||||||||||||||||||||||||||||
noexcept specifier(C++11) | ||||||||||||||||||||||||||||||||||||||||||||||
Exceptions | ||||||||||||||||||||||||||||||||||||||||||||||
Namespaces | ||||||||||||||||||||||||||||||||||||||||||||||
Types | ||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||
Specifiers | ||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||
Storage duration specifiers | ||||||||||||||||||||||||||||||||||||||||||||||
Initialization | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
Expressions | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Alternative representations | |||||||||||||||||||||||||||||||
Literals | |||||||||||||||||||||||||||||||
Boolean - Integer - Floating-point | |||||||||||||||||||||||||||||||
Character - String - nullptr(C++11) | |||||||||||||||||||||||||||||||
User-defined(C++11) | |||||||||||||||||||||||||||||||
Utilities | |||||||||||||||||||||||||||||||
Attributes(C++11) | |||||||||||||||||||||||||||||||
Types | |||||||||||||||||||||||||||||||
typedef declaration | |||||||||||||||||||||||||||||||
Type alias declaration(C++11) | |||||||||||||||||||||||||||||||
Casts | |||||||||||||||||||||||||||||||
Implicit conversions - Explicit conversions | |||||||||||||||||||||||||||||||
static_cast - dynamic_cast | |||||||||||||||||||||||||||||||
const_cast - reinterpret_cast | |||||||||||||||||||||||||||||||
Memory allocation | |||||||||||||||||||||||||||||||
Classes | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Class-specific function properties | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Special member functions | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Templates | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
Miscellaneous |
The preprocessor supports text macro replacement. Function-like text macro replacement is also supported.
Contents
|
[edit]Syntax
#define identifierreplacement-list(optional) | (1) | |
#define identifier( parameters) replacement-list(optional) | (2) | |
#define identifier( parameters, ... ) replacement-list(optional) | (3) | (since C++11) |
#define identifier( ... ) replacement-list(optional) | (4) | (since C++11) |
#undef identifier | (5) |
[edit]Explanation
[edit]#define
directives
The #define
directives define the identifier as macro, that is instruct the compiler to replace all successive occurrences of identifier with replacement-list, which can be optionally additionally processed. If the identifier is already defined as any type of macro, the program is ill-formed unless the definitions are identical.
[edit]Object-like macros
Object-like macros replace every occurrence of defined identifier with replacement-list. Version (1) of the #define
directive behaves exactly like that.
[edit]Function-like macros
Function-like macros replace each occurrence of defined identifier with replacement-list, additionally taking a number of arguments, which then replace corresponding occurrences of any of the parameters in the replacement-list.
The syntax of a function-like macro invocation is similar to the syntax of a function call: each instance of the macro name followed by a ( as the next preprocessing token introduces the sequence of tokens that is replaced by the replacement-list. The sequence is terminated by the matching ) token, skipping intervening matched pairs of left and right parentheses.
For version (2), the number of arguments must be the same as the number of parameters in macro definition. For versions (3,4), the number of arguments must be more than(until C++20)at least as many as(since C++20) the number of parameters (not counting ...
). Otherwise the program is ill-formed. If the identifier is not in functional-notation, i.e. does not have parentheses after itself, it is not replaced at all.
Version (2) of the #define
directive defines a simple function-like macro.
Version (3) of the #define
directive defines a function-like macro with variable number of arguments. The additional arguments (called variable arguments) can be accessed using __VA_ARGS__
identifier, which is then replaced with arguments, supplied with the identifier to be replaced.
Version (4) of the #define
directive defines a function-like macro with variable number of arguments, but no regular arguments. The arguments (called variable arguments) can be accessed only with __VA_ARGS__
identifier, which is then replaced with arguments, supplied with identifier to be replaced.
For versions (3,4), replacement-list may contain the token sequence | (since C++20) |
Note: if an argument of a function-like macro includes commas that are not protected by matched pairs of left and right parentheses (most commonly found in template argument lists, as in assert(std::is_same_v<int, int>); or BOOST_FOREACH(std::pair<int,int> p, m)), the comma is interpreted as macro argument separator, causing a compilation failure due to argument count mismatch.
[edit] Reserved macro names
A translation unit that includes a standard library header may not #define
or #undef
names declared in any standard library header.
A translation unit that uses any part of the standard library may not #define
or #undef
names lexically identical to:
(since C++11) |
except that | (since C++20) |
Otherwise, the behavior is undefined.
[edit]#
and ##
operators
In function-like macros, a #
operator before an identifier in the replacement-list runs the identifier through parameter replacement and encloses the result in quotes, effectively creating a string literal. In addition, the preprocessor adds backslashes to escape the quotes surrounding embedded string literals, if any, and doubles the backslashes within the string as necessary. All leading and trailing whitespace is removed, and any sequence of whitespace in the middle of the text (but not inside embedded string literals) is collapsed to a single space. This operation is called 'stringification'. If the result of stringification is not a valid string literal, the behavior is undefined.
When | (since C++11) |
A ##
operator between any two successive identifiers in the replacement-list runs parameter replacement on the two identifiers (which are not macro-expanded first) and then concatenates the result. This operation is called 'concatenation' or 'token pasting'. Only tokens that form a valid token together may be pasted: identifiers that form a longer identifier, digits that form a number, or operators +
and =
that form a +=
. A comment cannot be created by pasting /
and *
because comments are removed from text before macro substitution is considered. If the result of concatenation is not a valid token, the behavior is undefined.
Note: some compilers offer an extension that allows ## to appear after a comma and before __VA_ARGS__, in which case the ## does nothing when the variable arguments are present, but removes the comma when the variable arguments are not present: this makes it possible to define macros such as fprintf (stderr, format, ##__VA_ARGS__)
[edit]#undef
directive
The #undef
directive undefines the identifier, that is cancels previous definition of the identifier by #define
directive. If the identifier does not have associated macro, the directive is ignored.
[edit]Predefined macros
The following macro names are predefined in every translation unit.
denotes the version of C++ standard that is being used, expands to value 199711L(until C++11), 201103L(C++11), 201402L(C++14), 201703L(C++17), or 202002L(C++20) (macro constant) | |
(C++11) | expands to the integer constant 1 if the implementation is hosted (runs under an OS), 0 if freestanding (runs without an OS) (macro constant) |
expands to the name of the current file, as a character string literal, can be changed by the #line directive (macro constant) | |
expands to the source file line number, an integer constant, can be changed by the #line directive (macro constant) | |
expands to the date of translation, a character string literal of the form 'Mmm dd yyyy'. The first character of 'dd' is a space if the day of the month is less than 10. The name of the month is as if generated by std::asctime() (macro constant) | |
expands to the time of translation, a character string literal of the form 'hh:mm:ss' (macro constant) | |
(C++17) | expands to an std::size_t literal whose value is the alignment guaranteed by a call to alignment-unaware operator new (larger alignments will be passed to alignment-aware overload, such as operator new(std::size_t, std::align_val_t) (macro constant) |
The following additional macro names may be predefined by the implementations.
implementation-defined value, if present, typically used to indicate C conformance (macro constant) | |
(C++11) | implementation-defined value, if present (macro constant) |
(C++11) | expands to an integer constant of the form yyyymmL , if wchar_t uses Unicode, the date indicates the latest revision of Unicode supported (macro constant) |
(C++11) | expands to 1 if 'x' L'x' might be false for a member of the basic character set, such as on EBCDIC-based systems that use Unicode for wchar_t. (macro constant) |
(C++11) | expands to 1 if the implementation has strict std::pointer_safety (macro constant) |
(C++11) | expands to 1 if the program can have more than one thread of execution (macro constant) |
The values of these macros (except for __FILE__
and __LINE__
) remain constant throughout the translation unit. Attempts to redefine or undefine these macros result in undefined behavior.
Note: in the scope of every function body, there is a special function-local predefined variable named __func__, defined as a static character array holding the name of the function in implementation-defined format. It is not a preprocessor macro, but it is used together with | (since C++11) |
Language feature-testing macrosThe standard defines a set of preprocessor macros corresponding to C++ language features introduced in C++11 or later. They are intended as a simple and portable way to detect the presence of said features. See Feature testing for details. | (since C++20) |
Text Macro Tool
[edit]Example
Output:
Text Macrostructure
[edit]See also
Text Macro
C++ documentation for Macro Symbol Index |