I have just started using Sublime Text 2 and I find it very good, light and fast!

I like to use Emacs for LaTeX editing, but because I'm Portuguese, I have to use a lot of accents.Emacs has a plugin that automatically replaces accented characters with LaTeX control sequences on save and replaces them back to accents on open.I would like to write such a plugin for ST2, but I have absolutely no ideia where to start.

and you can take a look at many plugins [1] to get an idea of how they are structured. I have one [2] that uses on_load and on_post_save that might help you. You'd want to replace on_post_save with on_pre_save for your purposes.

Good luck! If you get stuck and need help, there are many quite talented plugin developers lurking on the forums that I'm sure could get you going in the right direction.

I must be trying to do something very stupid or my understanding of the API is really messed up... Anyway, the ideia is to select the whole buffer, replace the LaTeX accent control sequence with an Unicode accented character.

Here is some code that I wrote for myself to do a multiple find and replace. I'm sorry it doesn't have any comments (shame on me!), but I think it should be pretty self explanatory. Basically, if there is a selection, use it, if not, select the whole document. The key is to reverse the selection regions and process them backwards. When you find/replace, the offsets of the selections change and it is pretty hairy to keep them straight. Working backwards avoids that problem.

That's very interesting. Will please post it all again (and please use a code block so it's easier to read)? The code that I posted is from a TextCommand also, and the relevant portion prior to the line you referenced is

I have to disclaim something here: I haven't used this code in a month or two, so I don't know if there have been any changes to the TextCommand API. Whereas the API documentation calls the first parameter "edit", I have "self". Not sure if there is a problem there or not.

I can see 'Init!' printed on the console, but no 'I am here!'... :-S Therefore I know the plugin is being loaded and init'ed, but it does not run... Even stranger than that is that 'Init!' is printed twice...