Help us understand the problem. What is going on with this article?

「Sublime Text 2で全角スペースをハイライト表示するプラグインを作る」で、ハイライトとアウトラインできるようにしてみた

More than 5 years have passed since last update.

全角スペースをハイライト表示するプラグインを弄らせて頂きました。

変更点

参考サイトでは、パターンにマッチしている部分をアウトラインする
だけだったので、ちょっと改造して、アウトラインとハイライト両方できるようにしました。

ソース

AlwaysHighlight.py
#!/usr/bin/python
# -*- coding: utf8 -*-
import sublime
import sublime_plugin

class AlwaysHihghlight(sublime_plugin.EventListener):
    # highlight
    def highlight(self, view):
        pattern = view.settings().get('alwayshighlight_pattern')
        if pattern:
            view.add_regions('AlwaysHighlight_Highlight',view.find_all(pattern), "invalid", sublime.DRAW_EMPTY)
    # outline
    def outline(self, view):
        pattern = view.settings().get('alwayshighlight_outline_pattern')
        if pattern:
            view.add_regions('AlwaysHighlight_Outline',view.find_all(pattern), "invalid", sublime.DRAW_OUTLINED)

    def update(self,view):
        if view.settings().get('enable_alwayshighlight') == True:
            self.highlight(view)
            self.outline(view)
        else:
            view.erase_regions('highlight')

    # Called after changes have been made to a view.
    # @override
    def on_modified(self, view):
        self.update(view)

    # Called when a view gains input focus.
    # @override
    def on_activated(self, view):
        self.update(view)

    # Called when the file is finished loading.
    # @override
    def on_load(self, view):
        self.update(view)

設定

Preferences.sublime-settings
    // パッケージの有効化
    "enable_alwayshighlight": true,

    // ハイライトしたい文字パターンを設定
   "alwayshighlight_pattern": "[{}「」¥=”’+@:;・_ー 0-9A-Za-z]",

    // アウトラインしたい文字パターンを設定
    "alwayshighlight_outline_pattern": "[\n\t\r\n]",

以上です。

参考にさせていただきました m(_ _)m

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした