tags:

views:

185

answers:

3

I've got Xcode 3.2.1, and enjoy using it, but when I'm editing a file with hyperlinks in the text (for example, a comment with a reference: # see http://example.com) Xcode turns the text into a clickable hyperlink. This is a royal PITA when trying to edit that hyperlink, as it means I can't click inside it to edit a piece of the link -- I have to select it all and retype, or backspace/arrow-key eleventy-bajillion times to get to the part that needs changing.

Anyone know how to turn that off? I don't see it anywhere in the preferences, and have Googled until my fingers fell off, to no avail.

A: 

I dont know how to turn it off, but a workdaround (hack) would be to do a Replace All for http:// with "" (nothing). The remaining text will then be displayed as just plain text instead of a link.

Mihir Mathuria
Hm, that won't work for HTML documents I'm editing, where http:// is a critical part of the code. It might work for comments, though.Also, Xcode appears to recognize mailto: and other URL prefixes, so that's a pretty long list to have to replace throughout the document.Other ideas?
Zee
Hmmm...that puts us in a tight spot, doesnt it? Well, you can replace http:// with some special characters like http:$//$ and re-replace those with http:// once you are done. Same thing for other protocols. Hacks is all I can think :(
Mihir Mathuria
+1  A: 

Use the option key when selecting text in the link or more drastically, turn off syntax highlighting for the file.

ergosys
Any idea where Xcode stores the syntax highlighting rules? I wonder if there's an editable resources file somewhere.
Zee
A: 

Dug a little further, and I found that Xcode 3.x hides its syntax highlighting rules in xclangspec files, so editing the appropriate file will allow you to change the rules to an extent.

Files are stored here:

/Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources

In that directory, I opened BaseSupport.xclangspec and found the line that identified the URL protocol:

    Syntax = { 
        StartChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";           
        Chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;/:@&=+$,-_.!~*'()%#";
        Match =
            "^(acap|afp|afs|cid|data|fax|feed|file|ftp|go|gopher|http|https|imap|ldap|mailserver|mid|modem|news|nntp|opaquelocktoken|pop|prospero|rdar|rtsp|service|sip|soap\\.beep|soap\\.beeps|tel|telnet|tip|tn3270|urn|vemmi|wais|z39\\.50r|z39\\.50s)://([a-zA-Z0-9\\-_.]+/)?[a-zA-Z0-9;/?:@\\&=+$,\\-_.!~*'()%#]+$",
            "^(mailto|im):[a-zA-Z0-9\\-_]+@[a-zA-Z0-9\\-_\\.!%]+$",
            "^radar:[a-zA-Z0-9;/?:@\\&=+$,\\-_.!~*'()%#]+$",
        ); */
        Type = "xcode.syntax.url";
    };  

and changed the line for Match = to read:

Match = ();

This eliminated URL matching, but not mailto matching (which is in a separate rule below the first). I'm leaving that as an exercise for the reader ;-)

Obviously, I could have been more selective, and I suspect that changing the Type line would be sufficient as well. Also, future versions of Xcode will likely overwrite this change, so I'll have to investigate putting the change into my own copy of BaseSupport.xclangspec and see if sticking it in ~/Library/Application Support works.

Zee