Note that there are some explanatory texts on larger screens.

plurals
  1. POSublimeText3 plugin on_modified api implementation
    primarykey
    data
    text
    <p>I'm trying to develop some plugin for <strong>SublimeText3</strong>.</p> <p>The plugin is supposed to behave on every modification of the text, so looking at the api</p> <p><a href="http://www.sublimetext.com/docs/3/api_reference.html" rel="nofollow">http://www.sublimetext.com/docs/3/api_reference.html</a></p> <p><code>on_modified_async(view)</code> is the one to use I guessed.</p> <p>so the code goes like this:</p> <pre><code>#!/usr/bin/env python import sublime, sublime_plugin, socket class testCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.insert(edit, 0, "Hello, World1!") self.view.insert(edit, 0, "Hello, World2!") def on_modified_async(self, view): self.view.insert(edit, 0, "Hello, World3!") </code></pre> <p>This code works as intended for Hello, world 1&amp;2, but 3 is never fired.</p> <p>I'm quite new to both SublimeText plugin and python3.3 development. What do I miss? Thank you. // EDIT</p> <pre><code> MESSAGE = self.view.substr(0,50) TypeError: substr() takes 2 positional arguments but 3 were given </code></pre> <p>it looks I gave 2 positional arguments, not 3.</p> <hr> <p>I've got an error :AttributeError: 'MyEventListener' object has no attribute 'view'......What is wrong with my code(Edited)</p> <pre><code>import sublime, sublime_plugin, socket class testCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.insert(edit, 0, "Hello, World1!") class MyEventListener(sublime_plugin.EventListener): def on_modified_async(self,view): self.view.insert(edit, 0, "Hello, World2!") </code></pre> <p>--</p> <pre><code>Traceback (most recent call last): File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 279, in on_modified_async callback.on_modified_async(v) File "/Users/ken/Library/Application Support/Sublime Text 3/Packages/test/test.py", line 11, in on_modified_async self.view.insert(edit, 0, "Hello, World2!") AttributeError: 'MyEventListener' object has no attribute 'view' </code></pre> <hr> <p>This is the working code:</p> <pre><code>import sublime, sublime_plugin, socket class MarkdownLiveCommand(sublime_plugin.TextCommand): def run(self, edit): tcp(self.view) class MyEventListener1(sublime_plugin.EventListener): def on_modified_async(self, view): tcp(view) def tcp(view): #do the job </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload