I discovered something neat today. I have the following script in my .vimrc for all of my shells, as well as my local machine:
if &term =~ “xterm.*”
let &t_ti = &t_ti . “e[?2004h”
let &t_te = “e[?2004l” . &t_te
This isn’t really a problem with local instances of vim, but remote instances, if the connection is terminated while the editor is active, it will leave this edit mode enabled in the terminal client on OS X, whether it’s Terminal.app or iTerm2.
This results in all pastes getting surrounded with `
The fix, quite simply, is to issue a `reset` command to the terminal, which will restore it to normal operation.
Noting this error and fix down for future reference.