I have some text like:

  ID      :  <other stuff>
  NEWS    :  maybe blank
  PROFILE :  who knows
  DEL     :  xxx

Then somewhere else I want to put:

Begin <stuff>
  create tables ID NEWS PROFILE DEL;

The Begin and Execute lines are already there, I'd like to create the create tables...; line.

What I tried so far is yanking the text, then I recorded a macro where I create a new line, insert create tables, ma to set a mark (which I don't use often so there are no other marks in the doc), used :put! " to paste the selection with each element on it's own line, V, then 'a to return to the mark, then J, A, and finally add the semicolon.

This works while recording, but doesn't work while replaying. It seems the mark doesn't set even if I :delmarks a after running it.

  • 1
    Your technique seems to work fine for me, (with the caveat that the spacing after the J isn't quite right). Does this still fail for you if you run vim with vim --clean? – Rich Jan 13 at 16:49
  • 2
    It'd probably also help diagnose the issue if you are more specific about how your macro fails. What actually happens when you replay it? – Rich Jan 13 at 16:51
  • @Rich Well that's funny, vim --clean did it. What does vim --clean do, haven't seen it before? Thank you! – Josh Rumbut Jan 13 at 16:54
  • 1
    @Rich, thanks again, any suggestion what to do with this question? Write up a more detailed version of my process as a self-answer? – Josh Rumbut Jan 13 at 17:09
  • 2
    @JoshRumbut If you need to update the Q, editing is the best option. If you have an answer (e.g., you found a line in your vimrc that was the root cause), you could self-answer – D. Ben Knoble Jan 13 at 19:36

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.