有没有办法点击Firefox中的链接并在现有的VIM会话中打开文件?

bte*_*les 3 vim firefox firefox-addon

我知道如果链接具有以下格式,可以在html页面中打开链接(假设你使用的是Firefox)和TextMate:

<a href="txmt://open?url=file:///home/.../index.html.haml">View</a>
Run Code Online (Sandbox Code Playgroud)

但是有可能与VIM做类似的事情吗?也许是这样的:

<a href="vim://open?url=file:///home/.../index.html.haml">View</a>
Run Code Online (Sandbox Code Playgroud)

理想情况下,这将使用现有的VIM会话.

干杯,

伯尼

bte*_*les 7

找到了一种方法:

向Firefox添加协议处理程序

打开firefox并导航到about:config

添加以下键

    network.protocol-handler.warn-external.txmt   boolean   false

    network.protocol-handler.external.txmt        boolean   true

    #the last one is the path to the script we're about to create
    network.protocol-handler.app.txmt             string    ~/protocol_handler/prot.sh

    # I ended up needing this one as well on another machine, (no idea why)
    network.protocol-handler.expose.txmt          boolean   false
Run Code Online (Sandbox Code Playgroud)

创建脚本〜/ protocol_handler/prot.sh

将以下内容复制并粘贴到文件中:

#! /usr/bin/env ruby


file_result = ARGV[0].scan(/file\:\/\/((\w|\/|\.)*).*/)
file_path = file_result[0][0]


line_result = ARGV[0].scan(/\&amp\;line\=(\d*).*/)

if line_result
  line = line_result[0][0]
  system "gvim --remote-silent +#{line} #{file_path}"
else
  system "gvim --remote-silent #{file_path}"
end
Run Code Online (Sandbox Code Playgroud)

保存文件.

将文件模式更改为可执行文件:

$ chmod +x ~/protocol_handler/prot.sh
Run Code Online (Sandbox Code Playgroud)

我不确定你是否必须重新启动Firefox.

如果您确实想使用"vim://"协议,只需将网络密钥的结尾从txmt更改为vim即可.由于几个Rails插件(rails-footer,即)已经使用了txmt,我只是用它来避免重新编码.

玩得开心!伯恩斯