2

In the vimgolf challenge Words in parens, I use cw(ctrl-r")Esc to format "one" and then use w. to format the next two words, but the results are three copies of the text "(one)".

I use the :reg command to confirm the " unnamed register content equals "three", and I found another solution that formats the text correctly: use cw(ctrl-r ctrl-o")Esc to format "one", then use w. to format the next two.

But I'm still confused about the vim dot command in this case: why does the dot command not act the same as typing out the command again? There must be something I have missed about the vim dot command: I hope someone can give me an explanation about this case.

  • 2
    Have you read the help at :help c_CTRL-R_CTRL-O? I think it explains the difference pretty well – Christian Brabandt Jan 4 '18 at 12:17
  • 1
    In this case I think one should read :help i_CTRL-R_CTRL-O. I think this is a good question, because based on the content, I would think i_CTRL-R_CTRL-R should work similar to i_CTRL-R_CTRL-O, but it does not. It is not easy to understand why. Based on the docs, it seems the only difference is autoindent. But only i_CTRL-R_CTRL-O works as expected with the dot repeat. – Karl Yngve Lervåg Jan 4 '18 at 13:54
  • @ChristianBrabandt I already read this in vim before,<C-r>" is insert last delete or yank text, so 'w.' should same as 'wcw(<C-r>")Esc', then the last delete text became "two", so the 'w.' act result should "(two)" not "(one)", I don't know why – 9-bits Jan 5 '18 at 3:25
  • @ChristianBrabandt I confirm not set 'textwidth', 'formatoptions', or 'autoindent' in vimrc – 9-bits Jan 5 '18 at 3:33
  • @9-bits if you could create a reproducible example that would certainly help :) – Christian Brabandt Jan 5 '18 at 8:04
1

CTRL-R " insert text "one" (in default register) and . command just repeat insert the text one.
CRL-R CTRL-O " will insert current text in " register.

Maybe this will help too.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.