Edit Textmate syntax highlighting? - textmate

I have recently begun working with Objective-C in Textmate and noticed that the syntax highlighting is rather poor (a comment is the exact same color as a variable declaration).
I've never done syntax highlighting changes in Textmate and I'm having trouble figuring out how to correctly modify it.
For example the scope of a comment in an Objective-c file is:
source.objc.iphone
meta.implementation.objc
meta.scope.implementation.objc
meta.function-with-body.objc
but changing the colors on that changes alot more than just comments.
Does anyone know of a good place to start learning how to do this?

You can check the scope of your current cursor with ^ + Shift + P or Bundles > Bundle Development > Show Scode.
After you know the scope, you can create / change the color of it.
If the comment is not detected by the language grammar, you have to extend it. See the documentation for further information:
http://manual.macromates.com/en/language_grammars#language_grammars

Related

How do I add features to a syntax definition in Sublime Text without editing it?

For example, I would like to highlight #param, #type, and #return (i.e. epytext declarations) in my Python docstrings. I have figured out how to do this by simply editing Python/Python.tmLanguage; however, I would really like to put this in its own file, for a couple of reasons:
I don't always want to apply this highlighting. It's only for projects that use epydoc as their documentation tool; in other projects, I would want to highlight reStructuredText instead.
When Sublime Text updates, I'd like to have my own syntax as an overlay onto the included features. there are several features of Python that Sublime's author may choose to include in future versions and I don't want to have to manually figure out what I changed each time an update modifies the base Python syntax definition.
I keep my own editor configuration in version control, but I want that to be my own original stuff; I don't want to be burdened with having to carry copies (possibly proprietary? I don't know, it doesn't seem to have an independent license) of syntax definitions that come with Sublime.
Is there a way to put highlighting rules into a separate file, perhaps to only be applied to a particular scope?
Sounds to me like you want to create your own syntax file, inherit from the Python syntax file (source.python), and make your changes and customizations there. Sublime Text 2 uses the .tmLanguage format for syntax files, which is a bit complex, but fortunately most of the work has already been done for you, just by inheriting from source.python.
What you want to do is set up a regex pattern to match the substrings that you want to highlight, and give that pattern a name; something like punctuation.definition.comment.epydoc, to follow the convention set in Java/JavaDoc.tmLanguage. Then, check your color scheme file (ending in .tmTheme) and make sure there are settings for the scope that you've chosen -- or for one of its parents, since ST2 should use proper scoping rules for this sort of thing.
To use the syntax file you've created, stick it in Packages/User (so that ST2 doesn't overwrite it on upgrades), open a Python file in the editor, and then select your new syntax from the dropdown list in the bottom right corner of the window. If you've set up everything correctly, the epydoc strings should change to be whatever color you've set in your color scheme.
Good luck! And post a link somewhere when you've got a syntax file that works, so others can see and use it, as well!

Textmate Hide/Show Comments

Is there any way with TextMate to hide comments when editing code? Sometimes I want to see my code with the full comments and other times just want to see the code itself with all comments hidden. I was hoping there would be a way to toggle the display of comments, but haven't been able to find anything about this.
It is something you will need to edit on a language by language basis, but it is very doable. Inside of Bundles -> Bundle Editor -> Edit Languages you will find the language definition that TextMate uses to highlight that particular syntax. Inside of the syntax definition you will find foldingStartMarker and foldingStopMarker.
You can add comment syntax to those to allow the folding off comments themselves. It might be pretty tricky for single line comments, but multiline comments, that have both a clear and unique start and stop syntax, should work fine.
For PHP, for example, we are going to want to add \/\* to the start syntax, and \*\/ to the end syntax. You will need to reload the bundle for these changes to take effect (or restart TM).

Improving development flow and editing with XCode.

XCode is a little weak in the way that it obliges you to format code, and the restrictions it places on you. I'm thinking of things such as select a block of code and use tab to reposition the whole block, which is very useful for cleaning up indenting, amongst other things.
I realise that I can use an external editor (such as Sublime Text 2, which is superb and my daily editor) to edit code, but I'm wondering if there are any plugins or tools which exist out there which integrate into xcode to improve this development experience.
What kind of extensions exist for xcode, or if there aren't any, are there any lesser-known features which assist in improving this?
It's hard to give you an answer, as we don't know what features you use elsewhere that you think are missing in Xcode. For example, you can move a block of code in or out by pressing Cmd-{ or Cmd-}. Or you can "fix" the indenting by using ctrl-i as jrturton pointed out above. All of the emacs keybindings work. In fact, you should look over the key bindings in the prefs to see what other things are possible. Some of my favorites are:
1) Select a word and hit Cmd-E to make it the search term. Then Cmd-G to find the next instance.
2) F6 to step over in the debugger, F7 to step in and F8 to step out
3) As much as I hate command lines, gdb has a number of useful commands for calling methods while stopped at a breakpoint. You can call any function or C++ or Objective-C method using the call command. (Type help call at the gdb prompt to learn more.)
4) If your index is up-to-date, you should be able to Cmd-click on a symbol to go to it's definition, or option-Click to see its documentation.
Are those the sorts of things you're looking for? If not, please give examples of what you want. As far as I know there is no plug-in mechanism in Xcode 4, so no extensions exist.
Though the first answer is a great one (learned a lot from it), I wanted to add a little hint that helps me a lot when pasting codesnippets. A lot of times xCode copies indentation in a way I don't like and then I have to reindent the whole snippet.
What I started to do is jump to the first char in line (ctrl + a | cmd + ArrowLeft) and either paste the code immediatly, or indent by one or two before pasting, dependend if I'm in a function, loop etc.

Syntax highlighting in the Dokuwiki editor?

Is there any way to have syntax highlighting in the "editor" of dokuwiki?
By this I mean to have syntax highlighting in the actual editing window (in real time) just like using a text editor.
I have never seen anything like this but I was wondering if this is possible. Since I'm inputting a lot of LaTeX math thing into my dokuwiki, it would be great if it can be done.
Have a look at http://www.dokuwiki.org/plugin:aceeditor - I never tried it myself, but it seems to do what you're looking for.

Highlighting function calls in textmate

It feels like I'm missing something really simple here. I've been using Coda for a while now and I'm now playing around with Textmate. I'm unable to find a way to syntax highlight function calls in Textmate. I've poked around the documentation but can't believe I'd have to dig deep into Textmate and mess around with regex to make this work.
This is in textmate: http://imgur.com/acACa.png
Function calls are inheriting the foreground color. This is javascript but I get the same in PHP.
In Textmate, syntax coloring is entirely controlled by the language definition in the "bundle" of the relevant language. Both the PHP (HTML) and Javascript bundles give function definitions special treatment, but neither highlights function calls.
So yes, if you want to change this, you'll need to use the Bundle Editor and learn to edit the regex-based language definition (marked with an L icon in the bundle).

Resources