I have the following macro

let @f='ivoid function (void param^[o  {^M^M^[3kwi'

where ^[ represents ESC and ^M new line.

for some reason it does not execute anything after the 3k, I tried replacing the ^[ with a ^O which represents CTRL-O, but instead this made the macro paste some weird text at the end that seemed to come from the help page.

This macro is defined in ~/.vim/ftplugin/c.vim

  • you might want to have a look at :help startinsert – Naumann Oct 13 '17 at 0:35
  • 1
    I just tried your macro on my machine and it works properly. The first thing you should do is try to start vim without a .vimrc (vim -U NONE) and see if it works. If it works the problem comes from a setting in your .vimrc and you can debug that using this question. Also to do what you want I would prefer using a snippet than a macro, I use UltiSnips but you can read this question to choose the snippet manager which fits your need. – statox Oct 13 '17 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.