Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Xcode from converting text into hyperlinks?

Tags:

xcode

macos

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.

like image 302
Zee Avatar asked Dec 30 '22 07:12

Zee


2 Answers

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.

like image 128
Zee Avatar answered Jan 06 '23 20:01

Zee


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

like image 43
ergosys Avatar answered Jan 06 '23 20:01

ergosys