LoginSignup
0
0

More than 5 years have passed since last update.

SublimeText3のHTMLモードで単語補完が効かないことがあるのを直す

Posted at

Sublime Text 3 (Build 3103) の話です。最新版ではもしかしたら既に修正されてるかもしれません


HTMLモードでCtrl+Spaceでの単語補完が時折効かないことがあり、よく調べてみるとHTML文字列中のclassやstyle等の属性中のダブルクォートで囲まれた中にキャレットがある場合にそうなるらしい。

<div id="foobar"></div>
<div id="foob|"></div>

↑ 例えば|の位置にキャレットがある状態で単語補完を効かせた場合foobarが補完されることを期待するものの、何故か動作しない。これを修正したい。

修正する

PackageResourceViewer を使ってHTMLモードの挙動を書き換える。

  1. Ctrl+Shift+PPackage Control: Install Package からPackageResourceViewer をインストールする
  2. インストール後 Ctrl+Shift+PPackageResourceViewer: Open Resource を選択
  3. HTML を選択
  4. html_completions.py を選択

するとhtml_completions.pyファイルが開かれるので、その中の class HtmlTagCompletions 中の def on_query_completions(...): となっている箇所を次のように書き換える:

class HtmlTagCompletions(sublime_plugin.EventListener):
...
    def on_query_completions(self, view, prefix, locations):
        return []
...

(インデントに注意)
書き換えたらファイルを保存、HTMLモードの挙動が自動的に更新されるので、HTMLモードで動作を確認する。
お疲れ様でした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0