Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: yank to specific register in command-line mode

Tags:

vim

I can normally yank like this in the command-line mode :1,61y, but how do I yank that to, say, the "* (clipboard) register? :"*1,61y doesn't work, and :h c_y shows nothing.

like image 639
bongbang Avatar asked Oct 31 '14 02:10

bongbang


People also ask

How do I yank to a register in vim?

2.2. Vim is a powerful editor. First, in the Normal mode, we move our cursor on the last word “editor” and press yaw to yank the word editor into the unnamed register “”. Next, we move the cursor to an empty line and press p without giving a register name. We'll see the yanked text “editor” is pasted.

How do I paste a yanked line in terminal?

Yes. Hit Ctrl - R then " . If you have literal control characters in what you have yanked, use Ctrl - R , Ctrl - O , " .

What is Ctrl R in vim?

#vim. Use CTRL-R " when entering a command in command mode to paste the current paste buffer contents. Substitute " for a buffer name, % for current filename, / for last search term, + for the X clipboard or a host of other substitutions. CTRL-R also works in insert mode, no more skipping back to normal mode to paste!

What is vim command line mode?

vim has two "modes": COMMAND mode and INSERT mode. In COMMAND mode, you execute commands (like undo, redo, find and replace, quit, etc.). In INSERT mode, you type text. There is a third mode, VISUAL mode, that is used to highlight and edit text in bulk.


2 Answers

The register name comes after the range and yank portions:

:1,61y *

See :h :yank:

:[range]y[ank] [x]      Yank [range] lines [into register x].
like image 73
Wayne Avatar answered Oct 20 '22 00:10

Wayne


If you just type "*61yy while in command mode, you will yank the next 61 lines into the * buffer. (Note there is no colon before the command)

like image 29
Yep_It's_Me Avatar answered Oct 19 '22 23:10

Yep_It's_Me