Vim Tips Wiki
m (Paste vim registers in search or colon command-line instead of using the system clipboard moved to Paste registers in search or colon commands instead of using the clipboard: Page moved by JohnBot to improve title)
(Change <tt> to <code>, perhaps also minor tweak.)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{Tip
 
 
|id=490
 
|id=490
  +
|previous=489
|title=Paste vim registers in search or colon command-line instead of using the system clipboard
 
  +
|next=492
|created=June 20, 2003 8:30
+
|created=2003
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=rainbrot
 
|author=rainbrot
 
|version=5.7
 
|version=5.7
 
|rating=84/30
 
|rating=84/30
  +
|category1=Usage
|text=
 
  +
|category2=
 
}}
  +
You can type Ctrl-R to insert a register when in insert mode, or when typing in the command or search line. When you press Ctrl-R you will see <code>"</code> (quote) to prompt you to finish the command by entering a register. For example, press Ctrl-R then <code>a</code> to insert the contents of the <code>a</code> register, or Ctrl-R then <code>"</code> to insert the contents of the unnamed register.
   
  +
You can press <code>v</code> then move the cursor to visually select some text (say the text is "hello world"). If you press <code>y</code> the selected text is yanked (copied) into the unnamed register. You can now type <code>:%s/</code> then <code><C-r>"</code> (Ctrl-R quote), which would show the following in the command line:
To paste the contents of the unnamed register into the search or the colon command-line, press &lt;C-R&gt;" (including the quote, which represents the unnamed register), or replace the quote with the name of another register.
 
   
  +
<pre>
Use &lt;C-R&gt;&lt;C-W&gt; to paste the word under the cursor into colon commands.
 
  +
:%s/hello world
  +
</pre>
   
  +
You could complete the substitute command, to read, for example:
[[category:usage]]
 
   
  +
<pre>
}}
 
  +
:%s/hello world/goodbye everyone/gc
  +
</pre>
  +
  +
Type <C-r><C-w> to paste the word under the cursor into the command line, or <C-r><C-a> to paste the WORD.
  +
  +
==References==
  +
*{{help|c_CTRL-R}}
  +
*{{help|i_CTRL-R}}
  +
*{{help|WORD}}
  +
  +
==Comments==

Latest revision as of 05:33, 13 July 2012

Tip 490 Printable Monobook Previous Next

created 2003 · complexity intermediate · author rainbrot · version 5.7


You can type Ctrl-R to insert a register when in insert mode, or when typing in the command or search line. When you press Ctrl-R you will see " (quote) to prompt you to finish the command by entering a register. For example, press Ctrl-R then a to insert the contents of the a register, or Ctrl-R then " to insert the contents of the unnamed register.

You can press v then move the cursor to visually select some text (say the text is "hello world"). If you press y the selected text is yanked (copied) into the unnamed register. You can now type :%s/ then <C-r>" (Ctrl-R quote), which would show the following in the command line:

:%s/hello world

You could complete the substitute command, to read, for example:

:%s/hello world/goodbye everyone/gc

Type <C-r><C-w> to paste the word under the cursor into the command line, or <C-r><C-a> to paste the WORD.

References[]

Comments[]