Typically, you would do that with mouse selecting (perhaps CtrlIns or CtrlC after selecting) and then, when in the command/search line, middle-clicking (or ShiftIns or CtrlV).
Another way, is to write your command/search line in the text buffer with all the editing available in text buffers, starting with : and all, then, on the line, do: