30

Hi is there any way I can paste the yanked text from a vim buffer to a vim command line, as I need to search for some file names which appear in current open text and I have to manually type the file name after :e

Shubhanshu Mishra
  • 459
  • 2
  • 5
  • 10

5 Answers5

47

Yes you can use ctrl+r + " and can see this as a reference https://stackoverflow.com/questions/906535/how-to-copy-yanked-text-to-vi-command-prompt

Suvasish Sarker
  • 818
  • 7
  • 10
7

You can do <C-r>" to paste from the default register or <C-r>a to paste from register a.

romainl
  • 22,554
  • 2
  • 49
  • 59
5

If your cursor is on the filename before you go to command mode use Ctrl-rCtrl-f.

You could also use the command-line window for this, and then edit the command line like you would in the file buffer.

See :help c_CTRL-R_CTRL-F and :help command-line-window for more.

Thor
  • 6,419
  • 1
  • 36
  • 42
2

If you type q:, you will bring up your command-line history; this can be edited with conventional vim commands, including p.

I find accessing this history very useful, so I have the following three lines in my vimrc:

" Switch ; and : in normal and visual modes
noremap ; :
noremap : ;
noremap q; q:
cnoremap ;; <c-f>

The last one is the most useful -- with it you can either use q; or ;;; to access the command line history; and if you've already started typing a command then you can quickly hit ;; and gain access to your familiar vim keys. I find this easier than memorising a bunch of key chords (if I wanted that, I'd be using emacs).

evilsoup
  • 13,097
  • 3
  • 59
  • 80
0

<C-r>+ if you want to paste from system clipboard.

qed
  • 275
  • 2
  • 12