Using Xilinx PlanAhead and Vim

The downside to becoming a vim (or emacs for that matter) poweruser, is that every other editor seems lackluster. This includes e.g. the editor that is bulit into Xilinx PlanAhead. There is however the posibillity of having PlanAhead open text files in any editor of your choice (Tools→Options...→General→Text Editor). There are a few suggestions, mostly for Vim and Emacs users, but they all have the problem that a new [terminal] window will be opened for each opened file, which at least is not what I want. I want a single vim window to be opened when editing the first file, and each subsequent opened file to be added as buffers to the same vim instance.

Here's a way to do it:

It's nothing extraordinary, pretty much just making use of vim's client/server capabilites (which it needs to be compiled with) with some slight parameter massaging. The following method should work, but doesn't, at least on my system right now: Just putting the following in the custom editor field:

urxvt -e vim --servername planahead_vim --remote-silent +[line number] [file name]

The principle is good: vim in a terminal with additional parameters to make use of the client/server features (which need to be enabled at compiletime).

The symptoms for how it is not working are that PlanAhead seems to double-quote the line number and file name in a way that makes vim try to open a file where the quotes are part of the filename. I don't remember having this problem the last time I messed around with external editors, maybe I was using ISE at that time. Nevertheless, the workaround is simple:

In the PlanAhead custom editor field put

planahead_vim_shim [file name] [line number]

where the the shim is a bash script containing the following:

f=${1%\"} ; f=${f#\"}
l=${2%\"} ; l=${l#\"}
urxvt -e vim --servername planahead_vim --remote-silent +"$l" "$f"

Of course, you need to make sure the shim is stored somewhere accesible in your PATH (or you can make use of an absolute path of course), and that it has its executable flag set.

Apparently, as discussed here: https://forums.xilinx.com/t5/Design-Entry/PlanAhead-external-text-editor-doesn-t-work/td-p/414211 I'm not the only one getting quotes in my filename.