Posted on 09-05-2006
Filed Under (Computerworld) by esden

At work I have to use a pretty nasty Windows based development environment for a microcontroller.

You can configure it so that it starts a text editor of your liking to edit the source files. This editor gets called when you click on a file or on an error message in the compiler output. The DE also accepts a setting for parameters to the editor. There are two meta character codes. One is for the file (%F) and the second for the line the editor should jump to (%L). The problem is that it uses the same settings for the error invocation as for the normal file opening.

I wanted to use VIM7 and the new nice feature of tabs. As vim also supports remote invocation I decided that I want the DE to open the files in one central vim instance.

It took me some time to find out the correct command line setting so I want to share it with you.

gvim –servername <some_distinct_name> –remote-tab-silent +0%L %F

Now some explanations.

–servername is needed so that it always finds the correct vim window.

– remote-tab-silent is a directive that vim should start editing the file provided by %F in a remote window in a new tab if the file is not yet being edited. The “silent” addition makes vim not yield an error if there is no vim instance running yet, and start a new instance by itself.

The +0%L is there so that when %L is there vim jumps to that line but when %L is empty it does not jump to the end of file but to the beginning. That is why the 0 is there.

Ok I hope it is useful for someone. Have fun with VIM ;)

Update: Corrected the unvisible some_distinct_name ;)

    Read More   

Comments

Rabin on 22 June, 2006 at 3:27 pm #

Danke fürs Info! Vielleicht solltest Du auch erwähnen dass –servername ein Argument braucht. Im Beispiel fehlt der Name des Servers.


lurb on 10 July, 2006 at 7:13 pm #

Hi, great info, this inspired me to script a quick external file browser to open files in tabs from my project directories:

http://www.lacoctelera.com/lurb/post/2006/07/10/vim7-tabs-and-textmate-envy


esden on 11 July, 2006 at 1:28 pm #

I am very happy that I inspired you. Sadly I can not use your script because on mac you do not have server client availability. Or have I missed something? Otherwise it is very nice thing. I was just searching for something like this.


esden on 11 July, 2006 at 1:29 pm #

Ohh ja richtig … sollte ich erwähnen. Ich korrigier es gleich.


Post a Comment
Name:
Email:
Website:
Comments:
Creative Commons License Creative Commons License