For a while now, I've been dealing with a problem where when pasting a large amount of text, such as the code in this gist, into a file via vim, only part of the copied text gets pasted, then stops and gets stuck in "insert paste" mode. Why trying to press esc
on my computer, ^[
gets printed into the file. I find that the only way to get out of the "insert paste" mode is by using Ctrl
+ C
.
https://asciinema.org/a/nhDJfd1P8g7c2j1XgaJ8KCU7X
I've tried using vim --clean filename
, and it ends with the same result.
https://asciinema.org/a/60qpQsHIqegLdd3F9HdntNkRw
I've seen a few other questions similar to the predicament that I'm in, but all answers suggest that it's possible that Ctrl
+ S
was accidentally pressed during pasting, but this just isn't the case for me. I've never accidentally or purposefully pressed that key combination.
One thing I think might be important to note, is that this problem doesn't occur when using macvim. It only happens when using vim via the terminal. Additionally, I find that when I use tmux and then perform vim, as long as I use :set paste
to allow for proper spacing, I have no problem pasting the entire piece of text.
https://asciinema.org/a/a1Wya4OfqOfsllotrtkmTenaM
Here is the output of vim --version
:
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Aug 28 2022 16:44:20)
macOS version - x86_64
Included patches: 1-300
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_urxvt -tag_any_white
+arabic +find_in_path +mouse_xterm -tcl
+autocmd +float +multi_byte +termguicolors
+autochdir +folding +multi_lang +terminal
-autoservername -footer -mzscheme +terminfo
-balloon_eval +fork() +netbeans_intg +termresponse
+balloon_eval_term +gettext +num64 +textobjects
-browse -hangul_input +packages +textprop
++builtin_terms +iconv +path_extra +timers
+byte_offset +insert_expand +perl +title
+channel +ipv6 +persistent_undo -toolbar
+cindent +job +popupwin +user_commands
-clientserver +jumplist +postscript +vartabs
+clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +vim9script
+cmdline_hist +langmap -python +viminfo
+cmdline_info +libcall +python3 +virtualedit
+comments +linebreak +quickfix +visual
+conceal +lispindent +reltime +visualextra
+cryptv +listcmds +rightleft +vreplace
+cscope +localmap +ruby +wildignore
+cursorbind +lua +scrollbind +wildmenu
+cursorshape +menu +signs +windows
+dialog_con +mksession +smartindent +writebackup
+diff +modify_fname -sodium -X11
+digraphs +mouse -sound -xfontset
-dnd -mouseshape +spell -xim
-ebcdic +mouse_dec +startuptime -xpm
+emacs_tags -mouse_gpm +statusline -xsmp
+eval -mouse_jsbterm -sun_workshop -xterm_clipboard
+ex_extra +mouse_netterm +syntax -xterm_save
+extra_search +mouse_sgr +tag_binary
-farsi -mouse_sysmouse -tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o vim -lm -lncurses -liconv -lintl -framework AppKit -L/usr/local/opt/lua/lib -llua5.4 -mmacosx-version-min=12.0 -fstack-protector-strong -L/usr/local/lib -L/usr/local/Cellar/perl/5.34.0/lib/perl5/5.34.0/darwin-thread-multi-2level/CORE -lperl -L/usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/config-3.10-darwin -lpython3.10 -framework CoreFoundation -lruby.3.1 -L/usr/local/Cellar/ruby/3.1.2_1/lib
<c-s>
yourself, what you paste may contain this sequence, or others. I think that's the potential problem depicted by the answers you read. You could try:set paste
before actually pasting.:set paste
has no affect on anything, unless I'm using tmux + vim, to ensure proper spacing and alignment.