Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
148ad95966 | ||
|
|
dc3c860a25 | ||
|
|
551cf1e378 | ||
|
|
e9d8a6dd6e | ||
|
|
87141119fa | ||
|
|
17ca7f2616 | ||
|
|
04b88f15bd | ||
|
|
36f90560f4 |
@@ -1,6 +1,6 @@
|
||||
## Synopsis
|
||||
|
||||
This is a [Sublime Text 2](http://www.sublimetext.com/2) plugin.
|
||||
This is a plugin for [Sublime Text 2](http://www.sublimetext.com/2) and [3](http://www.sublimetext.com/3).
|
||||
|
||||
**Highlight whitespaces in documents**
|
||||
|
||||
@@ -21,6 +21,8 @@ Then clone this repository:
|
||||
|
||||
That's it!
|
||||
|
||||
Note for ST3 users: For Sublime Text 3, replace "2" with "3" in path names. (`%APPDATA%\Sublime Text 3` and so on)
|
||||
|
||||
## Options
|
||||
|
||||
Several options are available to customize the plugin look 'n feel. The
|
||||
|
||||
@@ -11,7 +11,10 @@ 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_last_whitespace": true
|
||||
}
|
||||
|
||||
Forked from https://github.com/SublimeText/TrailingSpaces/ by Jean-Denis Vauguet <jd@vauguet.fr>, Oktay Acikalin <ok@ryotic.de>
|
||||
@@ -27,6 +30,9 @@ import sublime_plugin
|
||||
DEFAULT_MAX_FILE_SIZE = 1048576
|
||||
DEFAULT_COLOR_SCOPE_NAME = "invalid"
|
||||
DEFAULT_IS_ENABLED = True
|
||||
DEFAULT_CHECK_SPACES = True
|
||||
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')
|
||||
@@ -39,7 +45,12 @@ def is_find_results(view):
|
||||
|
||||
# Return an array of regions matching whitespaces.
|
||||
def find_whitespaces_spaces(view):
|
||||
return view.find_all(' {2,}')
|
||||
last_whitespace = bool(hws_settings.get('highlight_last_whitespace',DEFAULT_LAST_WHITESPACE))
|
||||
regex = ' {2,}|\t | \t'
|
||||
if last_whitespace:
|
||||
regex += '| {1,}$'
|
||||
|
||||
return view.find_all(regex)
|
||||
|
||||
def find_whitespaces_tabs(view):
|
||||
return view.find_all('\t+')
|
||||
@@ -54,13 +65,15 @@ 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):
|
||||
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,
|
||||
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,
|
||||
tab_regions, tab_scope_name, '',
|
||||
sublime.DRAW_EMPTY)
|
||||
|
||||
|
||||
|
||||
@@ -9,5 +9,14 @@
|
||||
"highlight_whitespaces_file_max_size": 1048576,
|
||||
|
||||
// By default plugin is enabled or disabled (true|false)
|
||||
"highlight_whitespaces_enabled": true
|
||||
"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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user