Currently, I have two similar methods to replace the entire buffer with some other text (say in clipboard).
delete all lines:
paste text: "+P ( or similar:
visually select all lines: ggVG.
paste text: "+P.
However I couldn't seem to find an one-command-fire way to do that. The most close one I found is
:change command. But it doesn't seem to work well with registers. Of course I can create some function and/or map a key to do that. But before I could make all these customizations, I want to make sure:
Is there some built-in command to replace a range of lines with some other text? Like, you could
:%replace+to replace the entire buffer with text in clipboard?
1,$s/\_./\=@+is not a solution :P,
:%d|put+is closer, but not quite there.
\_.matches any character including newline.
:%d|put+fits the bill. It's short and memorable. The other command is just too arcane to remember and type correctly.