Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim in OSX: How to paste text from open window into a open file in vim?

In linux, I used Shift + Insert to paste anything in the system clipboard into the terminal. In Mac, there isn't an insert key - so, I'm left wondering how to do that ?

like image 509
TCSGrad Avatar asked Sep 15 '11 05:09

TCSGrad


People also ask

How do I paste in vim OSX?

In this mode, you can run Vim commands and navigate through the file. To go back to normal mode from any other mode, just press the Esc key. Vim has its own terminology for copying, cutting, and pasting. Copy is called yank ( y ), cut is called delete ( d ), and paste is called put ( p ).

How do I copy and paste text in vim?

We can use the “+p and <Ctrl+r>+ in normal and command mode, respectively. However, it might be more convenient if we use the <Ctrl+Shift+v> hotkey since it does the same thing as “+p. Similarly, <Ctrl+Shift+c> will yank the text into the + register to be available for pasting outside of Vim.


3 Answers

The standard Mac paste shortcut, Command-v, should paste the contents of the clipboard into vim, running in a terminal window, assuming vim is in insert mode. I just pasted the previous sentence into vim on my Mac, by that method. If you are new to Macs, and you have an Apple keyboard, the Command keys have an apple and a strange symbol resembling an octothorpe, with a loop at each corner. On my 3rd party keyboard, they are labeled with a diamond-shaped symbol.

like image 160
Michael Hansen Avatar answered Oct 20 '22 19:10

Michael Hansen


This works with Macvim. The copied text is placed in the + register then in the macvim buffer hit "+p and the text will be pasted into the buffer. I find this quicker than using command-v,comand-c.

If you're using console vim then it is placed in the . register. Hit ".p to paste the text from the clipboard.

like image 39
sashang Avatar answered Oct 20 '22 19:10

sashang


In Ubuntu, Shift+Insert is used to paste highlighted text, not to paste text copied in the buffer that was copied using Ctrl+C.

In macOS this functionality of pasting highlighted text can be done with ⇧Shift+⌘Command+V.

I hope this helps any users that are coming from Ubuntu.

like image 40
Etienne Lawlor Avatar answered Oct 20 '22 18:10

Etienne Lawlor