For me Bracket Highlighter plugin is not coloring and highlighting brackets but just underlining them in white.
Here is a snapshot:
Anyone knows of a solution?
I have modified my example based upon the comments of AGS - it now includes a couple of highlight options and the rest are outline. Thank you AGS and thank you to the original poster for creating this useful thread.
bh_core.sublime-settings
{
"bracket_styles": {
// This particular style is used to highlight
// unmatched bracket pairs. It is a special
// style.
"unmatched": {
"icon": "question",
"color": "brackethighlighter.unmatched",
"style": "highlight"
},
// User defined region styles
"curly": {
"icon": "curly_bracket",
"color": "brackethighlighter.curly",
"style": "highlight"
},
"round": {
"icon": "round_bracket",
"color": "brackethighlighter.round",
"style": "outline"
},
"square": {
"icon": "square_bracket",
"color": "brackethighlighter.square",
"style": "outline"
},
"angle": {
"icon": "angle_bracket",
"color": "brackethighlighter.angle",
"style": "outline"
},
"tag": {
"icon": "tag",
"color": "brackethighlighter.tag",
"style": "outline"
},
"single_quote": {
"icon": "single_quote",
"color": "brackethighlighter.quote",
"style": "outline"
},
"double_quote": {
"icon": "double_quote",
"color": "brackethighlighter.quote",
"style": "outline"
},
"regex": {
"icon": "regex",
"color": "brackethighlighter.quote",
"style": "outline"
}
}
}
whatever_theme_file_you_use.tmTheme
<!-- BEGIN Bracket Highlighter plugin color modifications -->
<dict>
<key>name</key>
<string>Unmatched</string>
<key>scope</key>
<string>brackethighlighter.unmatched</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FD971F</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bracket Curly</string>
<key>scope</key>
<string>brackethighlighter.curly</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FF0000</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bracket Round</string>
<key>scope</key>
<string>brackethighlighter.round</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#0000FF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bracket Square</string>
<key>scope</key>
<string>brackethighlighter.square</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#800080</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bracket Angle</string>
<key>scope</key>
<string>brackethighlighter.angle</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#AE81FF</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Bracket Tag</string>
<key>scope</key>
<string>brackethighlighter.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#FD971F</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Single Quote | Double Quote | Regex</string>
<key>scope</key>
<string>brackethighlighter.quote</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#AE81FF</string>
</dict>
</dict>
<!-- END Bracket Highlighter plugin color modifications -->
Edit your ~/Library/Application Support/Sublime Text 2/Packages/BracketHighlighter/bh_core.sublime-settings
And set "style" to "highlight" for each bracket type you want highlighted. Here is an example for curly brackets.
// User defined region styles
"curly": {
"icon": "curly_bracket",
"color": "entity.name.class",
"style": "highlight"
}
Restart Sublime.
I just spent 20 mins hunting and trying all the above etc. Finally found a comment elsewhere suggesting a restart; which fixed it and gave me a brief moment long enough to slap myself hard while it reloaded.
Related
I have defined a menulist in package.json:-
"preferences": [{
"name": "editor_url",
"title": "Editor URL:",
"type": "menulist",
"value": 0,
"options": [
{
"value": "0",
"label": "http://localhost:53421"
}
]
}]
How can we add options/menuitems to the menulist dynamically?
Any help would be appreciated. Thanks
To your "options" array I added:
{
"value": "1",
"label": "https://miskatonic.edu"
}
Then I tried the following as lib/main.js:
var preferences = require("sdk/simple-prefs").prefs:
console.log(JSON.stringify(preferences));
preferences.editor_url = 1;
console.log(JSON.stringify(preferences));
It didn't update the preferences display in Add-Ons Manager in real time, but after closing and re-opening preferences for the add-on, the other URL was displayed.
array = [
["sean", "started", "shift", "at", "10:30:00"],
["anna", "started", "shift", "at", "11:00:00"],
["sean", "started", "shift", "at", "10:41:45"],
["anna", "finished", "shift", "at", "11:30:00"],
["sean", "finished", "shift", "at", "10:48:45"],
["sean", "started", "shift", "at", "11:31:00"],
["sean", "finished", "shift", "at", "11:40:00"]
]
Few things to consider
if you look at sean's entries - there are 2 entries for 'start times' one at 10:30:00 and also at 10:41:45 . The system can record multiple 'start times' but only one 'Finished' time. The logic is to pair first 'started' & first 'finished' and combine them.
How to skip the duplicated 'start time' entries (such as Sean's) and get a desired output as below...
array = [
["sean", "started", "shift", "at", "10:30:00", "finished", "shift", "at", "10:48:45"],
["anna", "started", "shift", "at", "11:00:00", "finished", "shift", "at", "11:30:00"],
["sean", "started", "shift", "at", "11:31:00", "finished", "shift", "at", "11:40:00"]
]
Theres no easy way is it?
array.group_by(&:first).map do |person, events|
events.chunk { |_, event_type| event_type }.each_slice(2).map do |(_, (start, _)), (_, (finish, _))|
%W(#{p} started shift at #{start[4]} finished shift at #{finish[4]})
end
end
# => [
# => ["sean", "started", "shift", "at", "10:30:00", "finished", "shift", "at", "10:48:45"],
# => ["sean", "started", "shift", "at", "11:31:00", "finished", "shift", "at", "11:40:00"],
# => ["anna", "started", "shift", "at", "11:00:00", "finished", "shift", "at", "11:30:00"]
# => ]
started = {}
result = []
array.each do |name, *event|
if event[0] == "started" && !started[name]
result << (started[name] = [name] + event)
elsif event[0] == "finished" && started[name]
started[name].concat(event)
started[name] = nil
end
end
result
EDIT Completely agree with fotanus, BTW.
EDIT2 Forgot to change a variable name. Also: logic. You take each row in turn. started will contain any records that have started but not yet finished. So, take a row; if it's "started", and only if we don't know that that person already started, remember the start. If it's "finished", and only if we already know the person has started, finish up the record by appending the finish info.
In Sublime Text 3, I am trying to alternate a setting's value using the same shortcut, but with differing contexts. Basically, I want to alternate the draw_white_space setting between its three possible values: none, selection, and all.
I change the setting easily enough with three separate shortcuts/keymaps. Here is that code (working):
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "all",
}
},
{
"keys": ["ctrl+e", "ctrl+q"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "none",
}
},
{
"keys": ["ctrl+e", "ctrl+s"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "selection",
}
}
But, what I would really like is to be able to press ["ctrl+e", "ctrl+w"] and have it alternate through each possible value. Yes, it is a Visual Studio shortcut that I'm used to!
I created what looks to me like it should work, but it doesn't. At least not how I want it to. Here is that code (broken):
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "none",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "all" }
]
},
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "selection",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "none" }
]
},
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "all",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "selection" }
]
}
I have tested out my contexts, so I know they work. For instance, I can manually set all in my settings file, then the shortcut that checks for all will work the first time only. It nor the others will work after that.
Another thing I noticed is that my settings file does not change the draw_white_space value when the shortcut does work (including the three separate shortcuts). I assumed that might be default behavior - the settings changes may be per session - and that would be fine. But, I removed the setting completely and it is still the same behavior.
I am changing the file opened via the Preferences | Key Bindings - User menu, which opened the <Sublime Text>\Data\Packages\User\Default (Windows).sublime-keymap file.
Any ideas? Am I doing something wrong or missing something?
Maybe not what you want, but you can get that behavior with a pretty simple plugin.
import sublime
import sublime_plugin
class CycleDrawWhiteSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
white_space_type = view.settings().get("draw_white_space")
if white_space_type == "all":
view.settings().set("draw_white_space", "none")
elif white_space_type == "none":
view.settings().set("draw_white_space", "selection")
else:
view.settings().set("draw_white_space", "all")
After you save the plugin, bind your key binding to cycle_draw_white_space
i'm trying to do many things w topojson… combine 2 geojson files w 1 tsv, join on ELECT_DIV n NAME, promote that to the id, and keep 2012_POP from the tsv.
here's the command i'm using:
topojson -o electorates.json -e 2012_oz_population.tsv --id-property ELECT_DIV,NAME -p 2012_POP -s .0000005 --allow-empty -- electorates.geojson region.geojson
ELECT_DIV is in electorates.geojson. it is getting set as the ID on all the features, but each one is not getting the proper 2012_POP from the join with the tsv. however, at the top level, electorates and region are getting the last value of 2012_POP from the tsv, so it's joining in some way...
any ideas on what i'm doing wrong? do i need to do this in more than one topo command?
thanks!
UPDATE W REQUESTED INFO
2012_oz_population.tsv
CED_CODE NAME 2011_POP 2012_POP
101 Banks 154938 156527
electorates.geojson
"features": [
{ "type": "Feature", "properties": { "ELECT_DIV": "Lingiari", "STATE": "NT", "NUMCCDS": 335.0, "ACTUAL": 0.0, "PROJECTED": 0.0, "POPULATION": 0.0, "OVER_18": 0.0, "AREA_SQKM": 1352034.05, "SORTNAME": "Lingiari" }, "geometry": { "type": "MultiPolygon",
region.geojson
"features": [
{ "type": "Feature", "properties": { "scalerank": 5, "featurecla": "Admin-0 country", "labelrank": 5.0, "sovereignt": "Australia", "sov_a3": "AU1", "adm0_dif": 1.0, "level": 2.0, "type": "Dependency", "admin": "Ashmore and Cartier Islands", "adm0_a3": "ATC", "geou_dif": 0.0, "geounit": "Ashmore and Cartier Islands", "gu_a3": "ATC", "su_dif": 0.0, "subunit": "Ashmore and Cartier Islands", "su_a3": "ATC", "brk_diff": 0.0, "name": "Ashmore and Cartier Is.", "name_long": "Ashmore and Cartier Islands", "brk_a3": "ATC", "brk_name": "Ashmore and Cartier Is.", "brk_group": null, "abbrev": "A.C.Is.", "postal": "AU", "formal_en": "Territory of Ashmore and Cartier Islands", "formal_fr": null, "note_adm0": "Auz.", "note_brk": null, "name_sort": "Ashmore and Cartier Islands", "name_alt": null, "mapcolor7": 1.0, "mapcolor8": 2.0, "mapcolor9": 2.0, "mapcolor13": 7.0, "pop_est": -99.0, "gdp_md_est": -99.0, "pop_year": -99.0, "lastcensus": -99.0, "gdp_year": -99.0, "economy": "7. Least developed region", "income_grp": "5. Low income", "wikipedia": -99.0, "fips_10": null, "iso_a2": "-99", "iso_a3": "-99", "iso_n3": "036", "un_a3": "-099", "wb_a2": "-99", "wb_a3": "-99", "woe_id": -99.0, "adm0_a3_is": "AUS", "adm0_a3_us": "ATC", "adm0_a3_un": -99.0, "adm0_a3_wb": -99.0, "continent": "Oceania", "region_un": "Oceania", "subregion": "Australia and New Zealand", "region_wb": "East Asia & Pacific", "name_len": 23.0, "long_len": 27.0, "abbrev_len": 7.0, "tiny": -99.0, "homepart": -99.0 }, "geometry": { "type": "Polygon", "coordinates":
now that ive written that out (and figured out how to do basic markdown in Stackoverflow like a clown), i wonder, is it getting caught up on the join of the name in region.geojson?
thx much for the help #mbostock
so embarrassingly (as this has happened before to me), this was because i was using an outdated version of topojson.
after i updated the version to 1.2.3 (using npm update -g topojson) the properties mapped appropriately with the above command.
thx for responding regardless mike. i feared it was something on my end. alas, it was.
I use SublimeText since a few months with ruby, and I have a issue with comment auto-indentation. Indentation uses the comment's indentation, and indent all the following code using this indentation. I expect auto-indentation to ignore(at least) or set indent of previous code (at best), but not to take comment's indentation at all :
All my colleagues who use this editor have the same issue
Here's a sample code re-indented by SublimeText
class Test
def method1
end
#Bad indentation
def method2
somecode
end
def method3
somecode
end
end
Wanted :
class Test
def method1
end
#Bad indentation
def method2
somecode
end
def method3
somecode
end
end
I did a quickfix on
~/.config/sublime-text-2/Packages/Default/Indentation Rules - Comments.tmPreferences
Replacing
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>preserveIndent</key>
<true/>
</dict>
With
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>preserveIndent</key>
<false/>
</dict>
But it affects the default behavior, and I do prefer only affect Ruby's behavior.
Does anyone has greater solution ?
I suggest you use the BeautifyRuby ST2 package. You will also need to install the htmlbeautifier gem. Not only your comments, but also your code will be indented nicely.
If you use rvm, you might need to change the BeautifyRuby.sublime-settings to use the ruby installed by the rvm, instead of the system installed ruby. To find out the path of ruby you are using, type which ruby at the shell prompt. Paste this path as the value for the key named "ruby" such as:
"ruby": "/home/thetuxracer/.rvm/rubies/ruby-2.0.0-p247/bin/ruby"
and beautifyruby can be use with : edit->beautify ruby
or you can change it keybind:
{
"keys": ["alt+tab"],
"command": "beautify_ruby",
"context": { "key": "selector",
"operator": "equal",
"operand": "source.rb, source.ruby" }
},
{
"keys": ["alt+tab"],
"command": "reindent",
"args": {
"single_line": false
},
"context": { "key": "selector",
"operator": "not_equal",
"operand": "source.rb, source.ruby" }
},
I put this in my User settings file:
Preferences -> Settings -- User :
{
"color_scheme": "Packages/Theme - Refined/Color Schemes/Danro.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_size": 18.0,
"hot_exit": false,
"ignored_packages":
[
"Vintage"
],
"remember_open_files": false,
"save_on_focus_lost": true,
"tab_size": 2,
"translate_tabs_to_spaces": true
}
I tried to recreate your problem and I couldn't with these setting enforced.
For indentation following is the key setting
"tab_size": 2,
"translate_tabs_to_spaces": true
This works for me
{
"caret_style": "solid",
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"enable_tab_scrolling": false,
"folder_exclude_patterns":
[
".git",
".hg",
".sass-cache",
"log",
"tmp",
"script",
"vendor",
],
"font_size": 10,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
100
],
"scroll_past_end": false,
"tab_size": 2,
"translate_tabs_to_spaces": true
}
For ST3,
Preferences -> Settings -- User
Add following code:
{
"tab_size": 2
}
By default SublimeText uses hard-tabs that are 4 characters long.