I am trying to paste from the windows system clipboard into a terminal text editor like vim (or its clipboard and xterm-clipboard allowing variants like vim-gtx), nano or emacs to no avail.
I am mainly attempting it with vim-gtx since vim is my favorite editor -> but no matter what method I try, whether it is:
- Using :set paste and pasting with Ctrl-v,Shift-ctrl-v (this is the only method which pastes any clipboard content at all)
- Pasting with "*p or "+p (doesn't paste)
- Copying input to clip.exe (have tried xclip but this utility doesn't seem to work on WSL), and then pasting into vim.
AS mentioned above, pasting from the clipboard only seems to work when pressing Ctrl-v in insert mode (Shift-Ctrl-v inserts a '^', and "*p and "+p inserts an 'i' character or '^?'), and the pasted output always pastes onto a single line.
For example, a section of the default .bashrc file copied from VSCode:
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Will paste as the following into a terminal text editor:
# enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi
If making EOL characters visible, then a $ appears just after the final character. This problem occurs no matter which editor is used, from where the text is copied from, and no matter which pasting system is used (if the pasting is successful at all).
To sum up:
Ctrl-v in vim is the only way to paste anything, but pasting occurs on a single line only
"*p / "+p in vim does not paste as expected (but works in vim via git-for-windows, see note below)
- I'm unsure of how to paste from system clipboard into nano and emacs (ordinary pasting and piping output to windows clip and then pasting doesn't paste anything in these two programs - I can only paste after yanking/copying internally).
- So, it could be a problem (with all) varieties of vim on Ubuntu for Windows.
Thanks
Important Note: -When pasting with "*p on vim via git-for-windows (instead of Ubuntu bash), it pastes correctly (with new lines). But Vim (vim-gtx, or ppa version) via Ubuntu is unable to paste properly with "*p - it's looking to perhaps be a problem with vim being ported to