While programming I am regulary using the following two lines:
sprintf(buff,"%s", __func__);
putrsUART(buff);
Is it possible to set any keyboard shortcut to insert these two lines? E.g. when I type \sp in command mode, these functions get added at the cursor position in my file. Is this possible? And if so, how do I map my keys?
Thanks in Advance.
You can use abbreviations, which are designed for this.
:abbr spb sprintf(buff,"%s", __func__);
:abbr uart putrsUART(buff);
Use :help abbr for the gory details. Note that you need to type another character after the abbreviated form for vim to recognize them. This comes naturally for these as you will type ENTER as the next character. It is also possible to enter more than one line with abbreviations. Simply use <CR> where you want a new line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With