通过 ssh 使用 Macvim

发布于 2024-10-22 10:00:58 字数 261 浏览 7 评论 0原文

我的项目涉及在远程服务器上处理大型代码库。我经常编辑多个文件,因此来回 scp 文件是不可能的。 我已经按照我喜欢的方式设置了本地 Macvim,其中包含多个插件,包括 ctags。

是否有可能通过 ssh 使用 Macvim,以便我能够轻松浏览并打开本地运行的 Macvim 中的文件?

让 ctags 在不安装在远程服务器上的情况下工作会更好,但我怀疑不可能......

还有一个问题是远程服务器是用我不想使用的别人的 .vimrc 设置的,但无法覆盖。

My project involves working on a large codebase on a remote server. I'm constantly editing multiple files, so scp'ing files back an forth is not possible.
I've got my local Macvim setup just the way I like it, with multiple plugins including ctags.

It is at all possible to use Macvim over ssh in such a way that I am easily able to browse to and open files from within Macvim running locally?

Getting ctags to work without it being installed on the remote server would be even better but I suspect not possible...

Also an issue is the fact that the remote server is setup with someone else's .vimrc that I don't want to use, but can't overwrite.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

梦过后 2024-10-29 10:00:58

以下命令将通过 ssh 在 MacVim 中打开一个文件:

:e scp://[email protected]/path/to/file

我怀疑这可能不完全是您正在寻找的内容,因为它一次只会为您提供一个文件。

如果您可以在本地从目标系统挂载共享,那也可以。

The following command will open a file in MacVim over ssh:

:e scp://[email protected]/path/to/file

I suspect this might not be completely what you're looking for as it will only give you one file at a time.

If you could mount a share from the target system locally that would work as well.

雨巷深深 2024-10-29 10:00:58

使用 FUSE for macOS 项目中的 SSHFS。 https://github.com/libfuse/sshfs

Use SSHFS from the FUSE for macOS project. https://github.com/libfuse/sshfs

巴黎盛开的樱花 2024-10-29 10:00:58

我过去经常使用的一件事是打开一个 X-11 会话,然后连接到我的远程主机,并在 X 上使用 gvim。你将拥有一个完整的 GUI 版本的编辑器,它看起来像是正在运行本地,但一切实际上都是远程运行。

另一种选择是使用 VNC 远程控制远程主机上的会话。 Mac 上有多个 VNC 客户端。

您还可以使用 Mac SFTP 或 FTP 客户端进行连接,然后告诉它编辑一个或多个文件。如果您已将其配置为使用 MacVim 作为编辑器,则文件 I/O 将通过 FTP 连接透明地进行。这就是我在没有 ssh 功能时编辑远程网站的方式。

MacVim 和 vim 的 netrw 插件功能非常强大。如果您没有在 scp://... 命令上传递要编辑的文件名,vim 将显示常用的目录浏览器,让您从远程计算机中选择文件并在本地进行编辑。例如,这会通过 SSH 打开我的笔记本电脑与其自身的连接,并向我显示 vim 内的主目录:

vim scp://greg@localhost//Users/greg/

One thing I used to use a lot was to open an X-11 session, then connect to my remote host, and use gvim over X. You'll have a full-GUI version of the editor, it'll look like its running locally, but everything really is running remotely.

Another alternative is to use VNC to remotely control the session on the remote host. There are several VNC clients for the Mac.

You can also use a Mac SFTP or FTP client to connect, then tell it to edit a file or files. If you've configured it to use MacVim as your editor the file I/O will occur through the FTP connection transparently. That's how I edit remote websites when I don't have ssh capability.

MacVim and vim's netrw plugin is very capable though. If you don't pass a filename to edit on the scp://... command, vim will present the usual directory browser letting you select your file from the remote machine and edit it locally. For instance, this opens a connection from my laptop to itself via SSH and shows me the home directory inside vim:

vim scp://greg@localhost//Users/greg/
高速公鹿 2024-10-29 10:00:58

上面建议的 MacFUSE 不再维护。幸运的是,有一个继任者,OSXFUSE

我在 OS X 10.9 上使用 MacVim 以及 OSXFUSE 和 SSHFS 在远程 Linux 服务器上编辑代码。保存文本文件时,我遇到了短暂的延迟(1-3 秒),但除此之外,它就像使用本地文件系统一样。

MacFUSE as suggested above is no longer maintained. Luckily there is a successor, OSXFUSE.

I use MacVim on OS X 10.9 with OSXFUSE and SSHFS to edit code on a remote Linux server. I experience a short delay (1-3 seconds) when saving a textfile, but apart from that, it is like working with your local filesystem.

〃安静 2024-10-29 10:00:58

至于问题的 .vimrc 部分 文档 指出参数 -u 可能对你有帮助。

-u {vimrc} 读取文件 {vimrc} 进行初始化。

As for the .vimrc part of your question the documentation states that parameter -u may help you.

-u {vimrc} The file {vimrc} is read for initializations.

初吻给了烟 2024-10-29 10:00:58

对每个文件进行 scp 操作将是一件很痛苦的事情。

虽然 SSHFS 与 MacFuse 一起工作,但速度可能非常慢。我在工作中尝试过几次,用一根巨大的管道连接到一台封闭的服务器,虽然这个想法一开始看起来很优雅,但这是一种令人发狂的沙滩球体验。

服务器具体是如何设置的?您是以其他人的身份登录还是以您自己的身份登录 /home/username

如果是后者,您可以轻松地将所有与 Vim 相关的内容放在主目录中,并使用服务器的 Vim 几乎就像使用 MacVim 一样。你甚至可以在你的主目录中的某个地方构建 ctags 并使用它...

如果你以自己的身份登录但没有主目录,你可以将你的 Vim 内容放在你有写访问权限的地方,并使用 if 将其路径添加到 master .vimrc /else 检查您的用户名。

我还没有测试过这个解决方案,但我使用类似的技术来加载不同的设置,无论我是在我的 Mac 上还是在我的 Ubuntu 盒子上:

if has("gui_running")

  "various gui settings

  let os=substitute(system('uname'), "\n", "", "")
  if os == "Darwin" || os == "Mac"

    "Mac-specific settings

  elseif os == "Linux"

    "Linux-specific settings

  endif

endif

也许使用命令 whoami...

scp-ing for each files is going to be a pain in your ass.

While SSHFS with MacFuse works, it can be really really slow. I tried it a couple of times at work with a huge pipe to a close server and, while the idea seemed elegant at first, it was a maddening beachball-ridden experience.

How is the server setup exactly? Do you log in as someone else or as yourself with your own /home/username?

If the later you can easily put all your Vim-related stuff in your home directory and use the server's Vim almost like you'd use MacVim. You can even build ctags somewhere in your home directory and use it…

If you login as yourself but don't have a home directory you could put your Vim stuff somewhere you have write access and add its path to the master .vimrc with an if/else checking for your username.

I haven't tested this solution but I use a similar technique to load different settings wether I'm on my Mac or on my Ubuntu box:

if has("gui_running")

  "various gui settings

  let os=substitute(system('uname'), "\n", "", "")
  if os == "Darwin" || os == "Mac"

    "Mac-specific settings

  elseif os == "Linux"

    "Linux-specific settings

  endif

endif

Maybe with the command whoami

笑饮青盏花 2024-10-29 10:00:58

MacFuse是fuse的MAC版本。但不幸的是,他们不再维护该项目,并且它与 Snow Leopard 存在一些问题,但有

MacFuse is MAC version of fuse. But unfortunately they no longer maintained the project and it have some problems with Snow Leopard but there is a fix.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文