Qiang Li
Qiang Li

Reputation: 10855

pasting commands into macvim does not interpret as commands

I find that from Mac's system clipboard pasting a command into macvim, such as :set history?, it does not get interpreted as command in normal mode, rather, it is pasted into the buffer as text.

This is different behavior from my vim. My macvim info is

VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 30 2019 23:05:43)
macOS version
Included patches: 1-2234
Compiled by Homebrew
Huge version with MacVim GUI.  Features included (+) or not (-):

Upvotes: 1

Views: 72

Answers (1)

bk2204
bk2204

Reputation: 76489

The reason this is different has to do with the programs performing the paste. When you paste into MacVim, as a GUI program, it is aware of the paste command and pastes directly into the buffer, which is consistent with how almost all other Mac editor (and word processor) programs behave.

When you paste into a terminal Vim, you're pasting into the terminal itself, not Vim. As a consequence, the terminal just sends those characters on to the program (Vim) as if you'd typed them yourself. Vim, in this case, has no knowledge of where those characters came from and doesn't distinguish typed characters from pasted characters.

If you want to paste a command in command line mode, you can type q: to bring up a command line buffer. You can then paste and edit that command as you wish using normal Vim commands, pressing Enter to apply it.

Upvotes: 1

Related Questions