Sublime Forum

20091017 Beta

#1

20091017 is out now, with key bindings to toggle find options, as well as various other small requests.

Find flags (regex, case sensitive, etc) are now specified via the application options, which are accessible from python plugins via sublime.options(), eg., running sublime.options().set(“find.regex”, True) will turn regex mode on from a plugin.

Also now exposed to plugins is the ability to change the current search string (as shown in the find panel, and used by F3): overwrite the option “find.string” to change this.

The main new bit of functionality in this beta is an experimental API to add tracked regions to the view (say, what bookmarks do), which will be updated as the buffer is modified, and can optionally be drawn. The functions are likely to change, so I haven’t added them to the API reference, but in brief:

view.addRegions(key, regions, scope)
view.getRegions(key)
view.eraseRegions(key)

eg., addRegions(“findResults”, [sublime.Region(0, 100), sublime.Region(150, 200)], “string”)

The first argument, key, is a string used to retrieve the stored regions later. The second is simply the list of regions. The third argument is a scope name, which, if not blank, will be used to find the colors to draw the regions in.

getRegions can be used to retrieve previously set regions: this is handy if you’re trying to track a position in the buffer, as the regions will be updated to maintain their position when the buffer is modified.

I’m keen for feedback on the API, and if it’s sufficient for the plugins you want to write.

0 Likes

#2

How to use it? :unamused:

0 Likes

#3

Got it! Thanks.

0 Likes

#4

Nice work on the “find” stuff :smiley: I appreciate the shortcuts!

Is good that you can alter the search string now via plugins but one feature I really want (and Im sure others too) is that** when I record a macro, find/replace actions get recorded**… oh lord how much good stuff you could do with that :smile:
I could do a macro to regex search all html tags, then erase them… (stripHTMLTags.sublime-macro) fine I can do this via a plugin but I’m just giving one example of how this can be used, and many other people have no idea how they would do it via a plugin.

0 Likes

#5

FYI, I checked the JSP support and while it is included, it really does not do syntax highlighting. If you find a JSP somewhere and load it into the editor you’ll see what I mean.

0 Likes

#6

jon, this is what i have been looking for!! thanks:

sticky-search, see: pastie.org/private/ngrwvsgkmnmky133p6dz9w

usage:

<binding key="ctrl+shift+f,*" command="stickySearch add" /> <binding key="ctrl+shift+f,-" command="stickySearch clear" />

ctrl+shift+f followed by * will mark the selected word all over your file (if non selected it will use clipboard content)
ctrl+shift+f followed by - will clear the marking

note: to always add markings (till you clear) you can change line 18 from:

regions = ]

to

regions = view.getRegions(key)

jon, what strings can i use as 3rd param (i used ‘string’), what are my options?

0 Likes

#7

one thing is missing though - it doesn’t reflect on the minimap…

0 Likes

#8

You can use any scope name you wish, same as a tmLanguage file would, eg., “comment.block.c source.c++”

0 Likes

#9

[quote=“jps”]

You can use any scope name you wish, same as a tmLanguage file would, eg., “comment.block.c source.c++”[/quote]

it seems it use the foreground color as background, i think this is also why i can’t see it on the minimap.

0 Likes

#10

Yeah that’s right, it looks up the colour, uses it for the background, and then generates a contrasting colour to use as the foreground. I can’t say I’m that happy with this method, it should likely be replaced by a system that lets colour schemes explicitly assign colours to regions.

0 Likes

#11

well, anyway, this is the one of things i lacked on sublime text. this geek is happy :geek:

0 Likes

#12

one more issue with it, is that it is gets lost on hotExit unlike other selections…

0 Likes

#13

Thanks for the sticky highlight. I really missed it! :smiley:

0 Likes