0

If I go to this web page on my MacOS, hit Command+A to highlight all the text, Command+C to copy it, open vim, enter insert mode, and paste with Command+V, it looks like:

enter image description here

If I do exactly the same thing, but before pasting, I enter paste mode (:set paste), then enter insert mode, and paste, I get this:

enter image description here

At first I thought it was something in my .vimrc, so I commented out EVERYTHING in my .vimrc file, and it still happens. The screenshots are with a blank .vimrc file.

What's going on? Why is a mode specifically designed for pasting doing a worse job than regular mode?

Update: Upon further investigation, I realized that this only happens in neovim. vim works fine in both regular, and paste mode.

Update 2: On my MacOS, this seems to only happen when I'm SSHed into a Linux system using the MacOS Terminal app, where neovim is running. If I use the neovim that's on my MacOS (also with the Terminal app), it doesn't happen.

10
  • 1
    Er, set paste is supposed to avoid this. That's odd. What about vim --clean or vim -u NONE? Those can be technically different from a blank vimrc.
    – D. Ben Knoble
    Feb 4 at 20:05
  • Might also try running vim with --clean...that ensures a known/sane configuration. Are you sure the text is clean before Vim gets a hold of it? One test would be to do cat > /dev/null from a shell command line see what it looks like pasted there. (Ctrl-C afterwards to quit.) Certainly the source is clean but maybe your OS is doing something strange.
    – B Layer
    Feb 4 at 20:05
  • Sorry - just realized that this is happening in neovim - not vim. vim seems to work fine in both regular, and paste mode. Neovim doesn't have a --clean arg (which is how I realized I was using it), but does seem to support the -u NONE args, but those didn't help. Doing cat > /dev/null and pasting, it looks fine.
    – John
    Feb 4 at 20:17
  • 2
    @BLayer On my MacOS, I have the built-in "Terminal" open. I'm using it to SSH into a Linux system, where neovim is running. I just tried it without SSHing into the Linux system - just neovim on my MacOS, and it doesn't happen. This might explain why I had such a hard time initially replicating the issue. Sometimes it happened, and sometimes it didn't. It appears to only happen under very specific conditions. I just happen to match those conditions quite frequently
    – John
    Feb 4 at 20:47
  • 1
    Aha. I wouldn't be surprised then if it's like one switch/flag in the terminal emulator settings but like I said I'm Mac-less so 'fraid I won't be able to help with that. Take a look at the settings and see if there's anything about tab stops, control characters, encoding ... things like that that seem...well..."wrong". :)
    – B Layer
    Feb 4 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.