Sublimetext3 弹出拼写建议上下文菜单,在升华文本3中进行拼写检查
我在上下文菜单中编写了一个键绑定:Sublimetext3 弹出拼写建议上下文菜单,在升华文本3中进行拼写检查,sublimetext3,spell-checking,sublime-text-plugin,Sublimetext3,Spell Checking,Sublime Text Plugin,我在上下文菜单中编写了一个键绑定: 命令:上下文菜单 要查看拼写建议,但要按照它指向下一个单词的方式操作,并将光标放在单词末尾,thid不起作用。但是,如果光标位于单词内部或单词的开头,它确实会起作用。有没有一个简单的方法说,返回一个字符,然后打开上下文菜单 也可以在上下文菜单中使用ctrl+n和ctrl+p。假设上下文菜单已关闭默认绑定 最后使用了下面答案的建议,但只是稍微不同的解决方案,在命令运行后,将您带回单词的开头我这样做了: { "keys": ["ctrl+alt+w"],
命令
:上下文菜单
要查看拼写建议,但要按照它指向下一个单词的方式操作,并将光标放在单词末尾,thid不起作用。但是,如果光标位于单词内部或单词的开头,它确实会起作用。有没有一个简单的方法说,返回一个字符,然后打开上下文菜单
也可以在上下文菜单中使用ctrl+n
和ctrl+p
。假设上下文菜单已关闭默认绑定
最后使用了下面答案的建议,但只是稍微不同的解决方案,在命令运行后,将您带回单词的开头我这样做了:
{
"keys": ["ctrl+alt+w"],
// Force ability to bring up context menu
"command": "chain",
"context": [ { "key": "selection_empty", "operator": "equal", "operand": true } ],
"args": {
"commands": [
// ["move", {"by":"word", "forward": false, "extend": false}],
["sbp_move_word", {"direction": -1}],
["context_menu"],
["move", {"by":"wordends", "forward": true, "extend": false}],
] }
},
// Do not use "find_under_expand" if selection is made
{
"keys": ["ctrl+alt+w"],
"command": "chain",
"context": [ { "key": "selection_empty", "operator": "equal", "operand": false } ],
"args": { "commands": [
["sbp_move_word", {"direction": -1}],
// ["move", {"by":"word", "forward": false, "extend": false}],
["context_menu"],
["move", {"by":"wordends", "forward": true, "extend": true}],
] }
},
出于某种原因,我在使用常规移动命令时遇到了问题,但应该也能正常工作,因此在Subemacs one上对其进行了注释:[1]
安装:
[2] 将此添加到密钥绑定:
// Use "find_under_expand" if no selection is made
{
"keys": ["ctrl+super+alt+t"],
"command": "chain",
"context": [ { "key": "selection_empty", "operator": "equal", "operand": true } ],
"args": {
"commands": [
["find_under_expand"],
["select_word_beginning"],
["context_menu"],
] }
},
// Do not use "find_under_expand" if selection is made
{
"keys": ["ctrl+super+alt+t"],
"command": "chain",
"context": [ { "key": "selection_empty", "operator": "not_equal", "operand": true } ],
"args": {
"commands": [
["select_word_beginning"],
["context_menu"],
] }
},
expand命令下的find_将选择插入符号处的单词,这将使上下文菜单
始终按照拼写建议执行
第二个键绑定不使用_expand
下的查找_,因为这会导致选择已选择文本的多个实例
[3] 将其另存为
selectWordBeginings.py
目录中的某个位置:
import sublime, sublime_plugin
class SelectWordBeginningCommand ( sublime_plugin.TextCommand ):
def run ( self, edit ):
view = self.view
selections = view.sel()
if len ( selections ) == 0:
return
selection = selections[0]
if selection.a < selection.b:
newSelection = sublime.Region ( selection.b, selection.a )
view.selection.clear()
view.selection.add ( newSelection )
导入升华,升华插件
类SelectWordBeginingCommand(升华插件.TextCommand):
def运行(自我,编辑):
view=self.view
selections=view.sel()
如果len(选择)==0:
返回
选择=选择[0]
如果选择.a<选择.b:
newSelection=崇高区域(selection.b,selection.a)
view.selection.clear()
view.selection.add(新闻选择)
此命令将反转选定区域,以便插入符号始终位于单词的开头。当您选择“转到下一个拼写错误”时,该单词已高亮显示,但问题是光标位于单词的末尾。无论是否高亮显示,都需要将光标移动到单词的开头,然后弹出关联菜单。也许有一个函数可以将光标移动到单词的开头,而不是“扩展”下的
find\u吗?我使用submacs,这样他们就有了一个move word命令,但是如何将args
传递给它:[“sbp\u move\u word”,“args”:{“direction”:-1}],
。这是我尝试过的命令。@JSpen:我刚刚实现了一个新的解决方法,可以验证它是否总是提供拼写建议。Sublime Text 3中的默认程序内置了拼写检查器。这是我能找到的唯一一个程序,用于查找拼写错误的单词,但没有一个好的导航和选择方法。这就是我想要这个功能的原因。如果我不知道拼写,我还会使用谷歌拼写检查软件包。它必须查询谷歌,所以不是最快的。我会接受这个结果,因为它可以工作,但也会检查我的问题,因为我已经找到了解决方案。