Copy and paste in vim via keyboard between different mac terminals?

后端 未结 2 770
暖寄归人
暖寄归人 2021-02-01 06:48

Can anyone help me with this: I\'m trying to figure out how to copy and paste text between 2 different instances of vim on different terminals (using iterm2 or mac terminal). I

相关标签:
2条回答
  • 2021-02-01 07:31

    Could you add the output of :version?

    I can yank with yy or y in one Vim instance running in Terminal.app window A and put with p or P in another Vim instance running in Terminal.app window B with this line in my ~/.vimrc:

    set clipboard+=unnamed
    

    without using specific clipboard registers (* or +).

    And why do you have two Vim instances running in different terminals? SSH/local? If one is in an SSH session yanking/putting won't work because the two machines (local/remote) don't share the same clipboard(s).

    EDIT

    I suspected that Vim wasn't compiled with the right flag(s). Apparently that's the case.

    Since you are using Mac OS X's default Vim my opinion is that you shouldn't need to re-compile it or even compile anything as it often leads to more problem's than it's worth.

    Instead, download the latest MacVim build and use the (CLI) Vim executable within MacVim's bundle: it has all the same functionalities as MacVim (within the constraints of the CLI, of course).

    Add this line to your ~/.bashrc or ~/.profile or wherever you are used to put aliases and custom bash functions:

    alias vim='/path/to/MacVim.app/Contents/MacOS/Vim'
    
    0 讨论(0)
  • 2021-02-01 07:37

    If you want to copy an entire file into your target file.

    Open your target file in vim.

    Put your cursor where you want it and type the following:

    :r /path_to_file/file.ext

    This will copy an entire file to where your cursor is...

    0 讨论(0)
提交回复
热议问题