Twisted world of Esden

My small window to the world…

VIM7 Fun

TAGS: None

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 ;)

© 2009 Twisted world of Esden. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.