Search code examples
python-3.xvimconsoletmux

Copy from vim to python console in tmux


I have installed tmux.

tmux -V
tmux 2.3

Set my configure file.

cat  ~/.tmux.conf
set -g mouse on

Enter tmux and open a two vertical windows in it,open python3 console in the left,open vim in the right.

enter image description here

Now move my cursor at the beginning of the first line in the right with mouse.
Enter into normal mode and input 2yy+, to copy two lines in my + register.
Move cursor at the left python3 console window ,how can i paste content in + register into the python console? @Kent,do as you say:
1.Move cursor at the beginning of first line,and type "+2Y
2.Move cursor to the left window,and middle-click mouse,nothing happen. 3.press ctrl+b then press ] key.

enter image description here


Solution

  • first your vim should be compiled with +clipboard see vim --version | grep 'clipboard'

    To copy ( or delete ) in any vim register you can use the following syntex

    • "<register name><oprator><motion> (see :h registers )e.g.
      1. "ayy(copy current line in register a) or
      2. "bdd(delete current line in register b) or
      3. "*ce(delete to the end of the current work and place content in register * using c will also put you in insert mode
    • to copy whole line you can use yy
    • and system clipboard is mapped to either + or * ( depending on the os )

    so to copy the whole line into system clipboard you can use

    • "*yy or "+yy (depending on the os)

    or to copy 2 lines

    • "*2yy or "+2yy ( to copy current and the line after current line )

    once the content is copied in the system clipboard you can paste in tmux using ( command + v or ctrl + shift + v )

    or to map system clipboard with tmux paste buffer see https://unix.stackexchange.com/questions/67673/copy-paste-text-selections-between-tmux-and-the-clipboard#72340