0

I've started using Neovim on Windows/WSL through ConEmu. It all works pretty amazingly except one pretty major flaw:

When I paste content into Neovim and forget to enter insert mode before, Neovim will register the input as keyboard strokes and execute them as commands. Needlessly to say, this can get pretty ugly, pretty fast.

A contrived example for clarity: I need to copy some text from my browser. The text in question is "sp" (yes, this is completely stupid, but bear with me). As I paste this into ConEmu (CTRL-V), the terminal transfers the input to Neovim that parses it as commands because it's in normal mode. In this example Neovim will replace whatever character is at the cursor at the time with p.

Vim for Windows has this solved and will paste the content without changing mode (how does a pure Linux environment handle this?). The problem with that solution is that it is dependent on the Windows file system which is a lot harder to tweak/maintain compared to apt-get/Ubuntu/WSL as well other annoyances.

So, initially I thought I'd try to make Neovim detect if the input was directly from the keyboard and not any other source, if it was, switch to insert mode and handle it from there. But I'm frankly not sure if this is even possible (especially though WSL). I also tried to add a shortcut that makes Neovim enter insert mode on CTRL-V in the hopes that is would trigger first and then correctly paste the content.

Maybe I need another terminal than ConEmu?

Anyway, I'm out of ideas, hope you guys can help.

2 Answers 2

1

ConEmu shall not detect any "internal" modes of the application you run in the terminal. Actually, when you "paste" something, terminal does almost the same thing if you press same keys manually.

Well, except one major difference: ConEmu uses "bracketed paste mode", so the console application may determine if user paste something or press keys manually. So, it's the question to Neovim how to process/configure bracketed paste mode inside it.

1
0

In ConEmu settings, Keys & Marco -> Paste There is an option:

Multi-line paste: avoid unexpected command execution by < Enter > keypress

That's what you need.

Not the answer you're looking for? Browse other questions tagged or ask your own question.