通过SSH的vim + COPY + mac [英] vim + COPY + mac over SSH

查看:126
本文介绍了通过SSH的vim + COPY + mac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过ssh访问一个服务器,在该服务器上运行vim来编辑文件.当我尝试使用y或"+ y"将vim的文本从Mac(Lion)上拉入本地的编辑器时,它不起作用.我最终得到的是我在本地复制的文本.如果我只在其中使用p,它将起作用好吧.

I access a sever over ssh on which I run vim for editing files. When I try to yank text from vim into an editor locally on my mac (lion) either with y OR "+y it does not work. I end up with the text I copied last locally. It does work if I just use p within vim alright.

推荐答案

扩大Ray的答案…

当通过SSH在远程服务器上使用Vim 时,在Vim中执行的所有操作均在远程服务器上完成.您在其上运行的远程服务器远程Vim对本地计算机及其系统剪贴板的实践知识为零.

When you are using Vim on a remote server via SSH, everything you do in Vim is done on the remote server. The remote server and the remote Vim that you are running on it have zero practical knowledge of your local computer and its system clipboard.

因此,y永远不会将选中的文本放在本地剪贴板中.

Because of that, y will never put the yanked text in your local clipboard.

要从远程Vim 复制文本到本地计算机的剪贴板中,您有以下三种选择:

In order to copy a chunk of text from the remote Vim to your local machine's clipboard you have three options:

  • 用鼠标选择文本,然后像在任何Mac OS X应用程序中一样按 Cmd + C .

显然,这似乎是最简单的方法,但它至少具有三个限制:

Obviously, it seems to be the easiest but it has at least three limitations:

  1. 仅限于当前屏幕.如果您要拉动的文本没有完全显示,您将无法复制所有文本.

  1. It is limited to the current screen. If the text you want to yank is not displayed entirely you won't be able to copy all of it.

set mouse=a上播放效果不佳.使用此选项,任何用鼠标选择东西的尝试都会导致 visual 模式选择,该选择不能用 Cmd + C 复制.解决方法是,您可以使用 Alt +鼠标来选择文本,而无需进入 visual 模式,或者只是从远程~/.vimrc中删除此设置.

It doesn't play well with set mouse=a. With this option, any attempt to select something with the mouse will result in a visual mode selection which can't be copied with Cmd+C. As a workaround, you can use Alt+mouse to select the text without entering visual mode or simply remove this setting from your remote ~/.vimrc.

行号也会被复制.

  • 将选中的文本放在一个临时文件中,将其scp放入本地计算机,然后使用pbcopy将其放入系统剪贴板中.

  • Put the yanked text in a temporary file, scp it to your local machine and use pbcopy to put it in your system clipboard.

    该解决方案似乎有些麻烦,但是可以解决(问题本身也有些麻烦).多年来,我看到了许多不同的实现方式,从简单的一个衬板到客户端/服务器设置. 这里是一个,请随时谷歌搜索周围的人.

    This solution seems to be a little convoluted but it works (and the problem itself is also a little bit convoluted). Over the years I've seen a lot of different implementations ranging from simple one liners to client/server setups. Here is one, feel free to google around for others.

    使用X转发将本地剪贴板连接到远程剪贴板(如果可用).

    Use X-forwarding to connect your local clipboard to the remote clipboard if available.

    这篇关于通过SSH的vim + COPY + mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆