Using MacVim for script editing

Hi

I tried to set MacVim as a script editor, I have one annoyance: whenever I double click on a script in unity and it isn’t open in MacVim yet, MacVim would open the script alright, but the whole text will be selected and the fill will be scrolled all the way to the end.

This doesn’t happen when I double click on an error message - the cursor is then correctly positioned at the error line. This (and MacVim’s documentation) implies that MacVim supports the ODB External Editor protocol, but there is some miscommunication between Unity and MacVim (and only MacVim as Unitron doesn’t have this problem and I don’t see similar complaints about other editors).

Are there fellow MacVim users around who could confirm this problem or may be even suggest a solution?

cheers,
artem

FWIW, a snippet from MacVim documentation about its Extern Editor support (this is all I could find)

And while I’m at it: a code fragment form MacVim that seems to be responsible (from the method that converts from ODB External Editor protocol to the switches to underlying vim command):

    // Set selection using normal mode commands.
    NSString *rangeString = [args objectForKey:@"selectionRange"];
    if (rangeString) {
        NSRange r = NSRangeFromString(rangeString);
        [a addObject:@"-c"];
        if (r.length > 0) {
            // Select given range of characters.
            // TODO: This only works for encodings where 1 byte == 1 character
            [a addObject:[NSString stringWithFormat:@"norm %dgov%dgo",
                                                r.location, NSMaxRange(r)-1]];
        } else {
            // Position cursor on line at start of range.
            [a addObject:[NSString stringWithFormat:@"norm %dGz.0",
                                                                r.location]];
        }

        [d removeObjectForKey:@"selectionRange"];
    }

So it would seem that MacVim receives non-empty ‘selectionRange’ from Unity (I don’t see right away any other code that would change selection in MacVim)

femistofel: I stumbled on this thread searching if anyone is coding for Unity with vim. Even better, you’re rockin’ MacVim :slight_smile:

I’m not a unity user (yet), but check this editor out >> Vico. It offers vi key bindings with support for textmate bundle. Still quite early in development but definitely one to keep an eye on!

femistofel: just tested MacVim with Unity. on load the cursor is as the top of the page with nothing selected, but visual mode is selected. also if no other MacVim window is yet open, both the script and a separate blank window will load with sometimes the blank window being selected instead. i don’t have either of these issues loading from finder, transmit or terminal.

EDIT: changed “open untitled window” pref, no more blank window issue. still launches in visual mode. and or course code highlighting is weak (still seems best in Textmate w/ latest '09 bundle)

Hey, sorry to bump an old thread, but I found this while searching. Any update on this? When I click on an error message in Unity, it opens the right buffer, but it doesn’t go to the line. It’s really not a big deal since I usually just go #G, but it would be nice if it worked. Currently I’m using 7.4 with patches 1-183. This isn’t the brew version though; I cloned the MacVim repo and built myself.

Any suggestions?

BTW, more people should get on vim for Unity. WIth OmniSharp and things like Unite.vim, this thing is seriously amazing.

Nevermind, it’s working now for some strange reason.