I'm presuming (because you used the [macro] tag) that you want to set the "a
register to be a macro, that, when played back, inserts the provided lines.
One way to do that is the following:
let @a = "o"
\. "#include <iostream>\r"
\. "#include <string>\r"
\. "#define 1e9 + 7\r"
\. "typedef long long ll;\r"
\. "using namespace std;\r"
\. "int main(int argc, char ** argv){\r"
\. "\r"
\. "return 0;}\<Esc>"
The \
line continuations and .
concatenations aren't strictly necessary. You could include the whole lot in a single string, but this will look neater in your .vimrc
.
I don't think I'd actually use this myself, though. It would be cleaner to set up a mapping or command to do this, to use Kevin's solution, or to look into the several snippet plugins that provide this feature in a more flexible way.
If you actually just want the register to contain the text so that you can put
it with commands such as "ap
, you need to alter the code slightly:
let @a = "#include <iostream>\n"
\. "#include <string>\n"
\. "#define 1e9 + 7\n"
\. "typedef long long ll;\n"
\. "using namespace std;\n"
\. "int main(int argc, char ** argv){\n"
\. "\n"
\. "return 0;}"