粘贴大量代码至Iterm2时出现字符异常问题求助
Hey there, I’ve seen plenty of other users run into this exact problem with iTerm2 when pasting large blocks of text—especially into psql sessions! That weird OROROROR... duplication and garbled syntax you’re seeing is super common, and there are a few straightforward fixes.
Common Causes & Solutions
Enable Slow Paste in iTerm2
The most frequent culprit is iTerm2 pasting text too quickly, which messes up sync with psql. Here’s how to slow it down:- Open iTerm2 preferences (
Cmd + ,) - Go to the Profiles tab, select your active profile
- Switch to Advanced, scroll down to the Paste section
- Check "Use slow paste" and adjust the delay (10ms is a good starting point—tweak it if you still see issues)
- Open iTerm2 preferences (
Use psql’s Paste Mode
For psql-specific problems, you can temporarily disable psql’s auto-formatting features before pasting:- In your psql session, run
\set paste - Paste your SQL code
- After pasting, run
\set nopasteto revert to normal mode
- In your psql session, run
Verify Clipboard Permissions
Double-check that iTerm2 has access to your clipboard:- Open iTerm2 preferences → General tab
- Ensure "Allow clipboard access" is enabled (this prevents partial/missing text during pasting)
Lots of users report that enabling Slow Paste alone fixes the duplicate character issue you’re seeing. Give these steps a try—they should resolve the syntax errors and garbled text when pasting large SQL chunks.
内容的提问来源于stack exchange,提问作者Jwan622

