Compare commits

..

13 Commits

Author SHA1 Message Date
Will Bradley
f030fe86ee Add /Packages
The repository seemingly needs to be cloned into the Packages folder in order to work.
2015-02-17 13:02:06 -07:00
Kemal
42b9b62842 Merge pull request #10 from jackmaney/master
Added `highlight_whitespaces_enabled` summary to README
2014-06-06 14:06:12 +03:00
Jack Maney
e363121abb Added highlight_whitespaces_enabled summary to README
Documented feature in Issue #8 of the parent repository.
2014-01-17 19:37:38 -06:00
Kemal
0060617485 Merge pull request #9 from jethar/st3
Fix #7, add option to allow highlight on single space
2013-10-22 08:10:38 -07:00
Harjeet Singh
1df06d1ada Restored option to allow highlight on single space, but set as false by default 2013-10-21 19:14:30 +05:30
Harjeet Singh
1067d50461 Enabling by default again 2013-10-21 17:30:44 +05:30
Harjeet Singh
7c8152b0d6 Fixes for ST3 and disabling plugin by default 2013-10-21 17:20:29 +05:30
Kemal Hadimli
148ad95966 Hunt for spaces after tabs or tabs after spaces as well 2013-08-27 12:09:58 +03:00
Kemal Hadimli
dc3c860a25 remove the only tab character in the file 2013-08-27 12:09:00 +03:00
Kemal Hadimli
551cf1e378 Update commented file settings in .py head 2013-08-27 12:03:12 +03:00
Kemal Hadimli
e9d8a6dd6e Merge branch 'master' of git://github.com/ebergama/HighlightWhitespaces into ebergama-master
Conflicts:
	highlight_whitespaces.py
	highlight_whitespaces.sublime-settings
2013-08-27 12:00:04 +03:00
Peter Conerly
87141119fa added option to disable spaces or tabs 2013-08-27 11:55:33 +03:00
Ezequiel Bergamaschi
17ca7f2616 last whitespace property enabled 2013-08-20 22:05:50 -03:00
3 changed files with 55 additions and 16 deletions

View File

@ -12,7 +12,7 @@ Go to your `Packages` subdirectory under ST2's data directory:
* Windows: `%APPDATA%\Sublime Text 2`
* OS X: `~/Library/Application Support/Sublime Text 2/Packages`
* Linux: `~/.config/sublime-text-2`
* Linux: `~/.config/sublime-text-2/Packages`
* Portable Installation: `Sublime Text 2/Data`
Then clone this repository:
@ -33,6 +33,10 @@ menu.
The default toggle highlight shortcut is ```ctrl+alt+w``` (```cmd+alt+w``` for OS X)
### Disable highlighting when Sublime Text starts up
Change `highlight_whitespaces_enabled` from the default of `true` to `false`.
### Change the highlighting color
One may also change the highlighting color, providing a scope name such

View File

@ -11,7 +11,11 @@ Config summary (see README.md for details):
"highlight_whitespaces_space_highlight_scope_name": "invalid",
"highlight_whitespaces_tab_highlight_scope_name": "invalid",
"highlight_whitespaces_file_max_size": 1048576,
"highlight_whitespaces_enabled": true
"highlight_whitespaces_enabled": true,
"highlight_whitespaces_check_spaces": true,
"highlight_whitespaces_check_tabs": true,
"highlight_whitespaces_single_space": false,
"highlight_last_whitespace": true
}
Forked from https://github.com/SublimeText/TrailingSpaces/ by Jean-Denis Vauguet <jd@vauguet.fr>, Oktay Acikalin <ok@ryotic.de>
@ -27,19 +31,37 @@ import sublime_plugin
DEFAULT_MAX_FILE_SIZE = 1048576
DEFAULT_COLOR_SCOPE_NAME = "invalid"
DEFAULT_IS_ENABLED = True
DEFAULT_CHECK_SPACES = True
DEFAULT_SINGLE_SPACE = False
DEFAULT_CHECK_TABS = True
DEFAULT_LAST_WHITESPACE = False
#Set whether the plugin is on or off
hws_settings = sublime.load_settings('highlight_whitespaces.sublime-settings')
hws_enabled = bool(hws_settings.get('highlight_whitespaces_enabled',
DEFAULT_IS_ENABLED))
def get_settings():
s = sublime.load_settings('highlight_whitespaces.sublime-settings')
return s
# Determine if the view is a find results view
def is_find_results(view):
return view.settings().get('syntax') and "Find Results" in view.settings().get('syntax')
# Return an array of regions matching whitespaces.
def find_whitespaces_spaces(view):
return view.find_all(' {2,}')
hws_settings = get_settings()
last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE))
single_space = bool(hws_settings.get('highlight_whitespaces_single_space',DEFAULT_SINGLE_SPACE))
if single_space:
regex = ' +'
else:
regex = ' {2,}|\t | \t'
if last_whitespace:
regex += '| {1,}$'
return view.find_all(regex)
def find_whitespaces_tabs(view):
return view.find_all('\t+')
@ -47,6 +69,8 @@ def find_whitespaces_tabs(view):
# Highlight whitespaces
def highlight_whitespaces(view):
hws_settings = get_settings()
max_size = hws_settings.get('highlight_whitespaces_file_max_size',
DEFAULT_MAX_FILE_SIZE)
space_scope_name = hws_settings.get('highlight_whitespaces_space_highlight_scope_name',
@ -54,14 +78,16 @@ def highlight_whitespaces(view):
tab_scope_name = hws_settings.get('highlight_whitespaces_tab_highlight_scope_name',
DEFAULT_COLOR_SCOPE_NAME)
if view.size() <= max_size and not is_find_results(view):
space_regions = find_whitespaces_spaces(view)
view.add_regions('WhitespacesHighlightListener',
space_regions, space_scope_name, '',
sublime.DRAW_EMPTY)
tab_regions = find_whitespaces_tabs(view)
view.add_regions('WhitespacesHighlightListener2',
tab_regions, tab_scope_name, '',
sublime.DRAW_EMPTY)
if hws_settings.get('highlight_whitespaces_check_spaces', DEFAULT_CHECK_SPACES):
space_regions = find_whitespaces_spaces(view)
view.add_regions('WhitespacesHighlightListener',
space_regions, space_scope_name, '',
sublime.DRAW_EMPTY)
if hws_settings.get('highlight_whitespaces_check_tabs', DEFAULT_CHECK_TABS):
tab_regions = find_whitespaces_tabs(view)
view.add_regions('WhitespacesHighlightListener2',
tab_regions, tab_scope_name, '',
sublime.DRAW_EMPTY)
# Clear all white spaces

View File

@ -1,13 +1,22 @@
{
// Spaces color is determined by scope (default, "invalid")
// Spaces color is determined by scope (default, "invalid")
// "highlight_whitespaces_space_highlight_scope_name": "Whitespaces.space.highlight",
// Tabs color is determined by scope (default, "invalid")
// Tabs color is determined by scope (default, "invalid")
// "highlight_whitespaces_tab_highlight_scope_name": "Whitespaces.tab.highlight",
// Max file size to search
// Max file size to search
"highlight_whitespaces_file_max_size": 1048576,
// By default plugin is enabled or disabled (true|false)
"highlight_whitespaces_enabled": true
// By default plugin is enabled or disabled (true|false)
"highlight_whitespaces_enabled": true,
// Whether to check for spaces
"highlight_whitespaces_check_spaces": true,
// Whether to check for tabs
"highlight_whitespaces_check_tabs": true,
// Allow the highlighting of the last whitespace, one or more time
"highlight_last_whitespace": true
}