Permalink
Browse files

Make "Open in Vim" Javascript more robust

  • Loading branch information...
jmettraux committed Apr 1, 2017
1 parent 20abeef commit 1054165ebbda8741670cc1638898849cb44e3d18
Showing with 10 additions and 4 deletions.
  1. BIN out/images/20170331_automator.png
  2. +10 −4 posts/20170331.md
Binary file not shown.
View
@@ -30,10 +30,12 @@ Here are the two pieces of code, the Javascript one:
<pre><code class="javascript">
function run(input, parameters) {
var m = input.toString().match(/([^\s\/:]+\/[^\s:]+)(:[0-9]+)?/);
var m = input.toString().match(/( [^\s\/:]*\/[^\s:]+)(:[0-9]+)?/);
if (m[2]) return "vim +" + m[2].substring(1) + " \"" + m[1] +"\"";
return "vim \"" + m[1] +"\"";
var m1 = m[1].trim();
var m2 = m[2] ? "+" + m[2].substring(1) + " " : "";
return "vim " + m2 + m1;
}
</code></pre>
@@ -54,7 +56,11 @@ end run
&nbsp;
**Update**
**Update 2017-03-31**
For those of you using iTerm2, here is a post by [Luca Guidi](https://lucaguidi.com/) on how to do it: ["Click on stack trace to open a file with NeoVim"](https://coderwall.com/p/3xwkcq/click-on-stack-trace-to-open-a-file-with-neovim).
**Update 2017-04-01**
Made Javascript more robust.

0 comments on commit 1054165

Please sign in to comment.