现象:
08:19:07 SQL> ^[[200 粘贴文本 ~
在命令行终端粘贴文本,首尾会自动添加其它特殊字符。
原因:
bracketed paste mode :目的是为了区分是自己编辑的还是粘贴过来的,对于粘贴过来的需要编辑后才能运行,所以才有前缀和后缀
解决方案:
1、命令行:输出 printf '\e[?2004l' ;回车即可关闭 bracketed paste mode。
2、vim 编辑器关闭 bracketed paste mode,需要编辑 .vimrc 文件,添加如下配置:
" Code from:
" http://stackoverflow.com/questions/5585129/pasting-code-into-terminal-window-into-vim-on-mac-os-x
" then https://coderwall.com/p/if9mda
" and then https://github.com/aaronjensen/vimfiles/blob/59a7019b1f2d08c70c28a41ef4e2612470ea0549/plugin/terminaltweaks.vim
" to fix the escape time problem with insert mode.
"
" Docs on bracketed paste mode:
" http://www.xfree86.org/current/ctlseqs.html
" Docs on mapping fast escape codes in vim
" http://vim.wikia.com/wiki/Mapping_fast_keycodes_in_terminal_Vim
if !exists(“g:bracketed_paste_tmux_wrap”)
let g:bracketed_paste_tmux_wrap = 1
endif
function! WrapForTmux(s)
if !g:bracketed_paste_tmux_wrap || !exists(’$TMUX’)
return a:s
endif
let tmux_start = “<Esc>Ptmux;”
let tmux_end = “<Esc>\”
return tmux_start . substitute(a:s, “<Esc>”, “<Esc><Esc>”, ‘g’) . tmux_end
endfunction
let &t_ti .= WrapForTmux("<Esc>[?2004h")
let &t_te .= WrapForTmux("<Esc>[?2004l")
function! XTermPasteBegin(ret)
set pastetoggle=
set paste
return a:ret
endfunction
execute “set =<Esc>[200~”
execute “set =<Esc>[201~”
map XTermPasteBegin(“i”)
imap XTermPasteBegin("")
vmap XTermPasteBegin(“c”)
cmap
cmap
注意:不要使用 :set paste 粘贴上面文本