Search code examples
vim

In Vim, is there a way to paste text in the search line?


I want to search for $maximumTotalAllowedAfterFinish and replace it with $minimumTotalAllowedAfterFinish. Instead of typing the long text:

:%s/$maximumTotalAllowedAfterFinish/$minimumTotalAllowedAfterFinish/g

Is there a way to COPY these long variable names down into the search line, since, on the command line I can't type "p" to paste?


Solution

  • You can insert the contents of a numbered or named register by typing CTRLR {0-9a-z"%#:-=.}. By typing CTRL-R CTRL-W you can paste the current word under the cursor. See:

    :he cmdline-editing
    

    for more information.