To copy text to the clipboard in Vim, you can use the y
key followed by a motion command. The y
key stands for “yank” and will copy the text to the clipboard. The motion command specifies the range of text that you want to copy.
For example, to copy a single line, you can use the yy
command. This command will copy the current line to the clipboard.
To copy multiple lines, you can use the <number>yy
command. For example, to copy three lines, you can use the 3yy
command. This command will copy the current line and the two lines below it to the clipboard.
You can also use other motion commands to specify the range of text that you want to copy. For example, to copy from the current position of the cursor to the end of the line, you can use the y$
command. To copy from the current position of the cursor to the end of the document, you can use the yG
command.
Once you have copied the text to the clipboard, you can paste it using the p
key.
Note that in Vim, the clipboard is not the same as the system clipboard. To copy text to the system clipboard, you will need to use a system-specific command or use a Vim plugin that provides this functionality.