擅长:python、mysql、java
<p>下面是一个如何将光标移动到行尾的示例。应该怎样概括才是显而易见的!在</p>
<p>关于<a href="https://www.sublimetext.com/docs/3/api_reference.html" rel="nofollow noreferrer">API reference</a>。在</p>
<pre class="lang-py prettyprint-override"><code>import sublime
import sublime_plugin
class MoveToEolCommand(sublime_plugin.TextCommand):
def run(self, edit):
# get the current "selection"
sel = self.view.sel()
# get the first insertion point, i.e. the cursor
cursor_point = sel[0].begin()
# get the region of the line we're on
line_region = self.view.line(cursor_point)
# clear the current selection as we're moving the cursor
sel.clear()
# set the selection to an empty region at the end of the line
# i.e. move the cursor to the end of the line
sel.add(sublime.Region(line_region.end(), line_region.end()))
</code></pre>